home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_318 / xoper / xoper.a < prev    next >
Text File  |  1992-05-06  |  150KB  |  6,570 lines

  1. ******************************************
  2. *                     *
  3. * Xoper 2.2 Copyright (C) Werner Gunther *
  4. *                     *
  5. ******************************************
  6. *  Written for the A68K V2.6 Assembler     *
  7. *      by Charlie Gibbs and         *
  8. *       Brian R. Anderson         *
  9. *                     *
  10. *  Do not use Smallcode/Smalldata when     *
  11. *          linking             *
  12. ******************************************
  13. ;DEBUG SET 1
  14.         XREF    _LVOSwitch
  15.         XREF    _LVOAddTask
  16.         XDEF    _SysBase
  17. sysbase     equ     4
  18.  
  19. CALL        MACRO
  20.         xref    _LVO\1
  21.         move.l  \2,a6
  22.         jsr     _LVO\1(a6)
  23.         ENDM
  24. LIBCALL     MACRO
  25.         xref    _\1
  26.         jsr     _\1
  27.         ENDM
  28.  
  29. ADDCMD        MACRO
  30. cmdnum        set     cmdnum+1
  31.         dc.b    \1,0
  32.         ENDM
  33.  
  34. ;Program startup. If called from DOS we
  35. ;use segment splitting to detach
  36. ;from our DOS-task.
  37. start        moveq   #3,d0
  38.         lea     dummyinput,a1
  39. getparm     move.b  (a0)+,(a1)+
  40.         dbf     d0,getparm
  41.         move.b  #$0a,in
  42.         lea     conname(PC),a1
  43.         move.l  sysbase,a0
  44.         lea     350(a0),a0
  45.         CALL    FindName,sysbase
  46.         move.l  d0,condev
  47.         lea     dosname(PC),a1
  48.         move.l  sysbase,a0
  49.         lea     378(a0),a0
  50.         move.l  a0,-(a7)
  51.         CALL    FindName,sysbase
  52.         move.l  d0,dosbase
  53.         move.l  0(a7),a0
  54.         lea     gfxname(PC),a1
  55.         CALL    FindName,sysbase
  56.         move.l  d0,gfxbase
  57.         move.l  (a7)+,a0
  58.         lea     intuiname(PC),a1
  59.         CALL    FindName,sysbase
  60.         move.l  d0,intuibase
  61.         move.l  d0,a0
  62.         move.l  $38(a0),a0
  63.         move.w  12(a0),d0
  64.         sub.w   #550,d0
  65.         move.w  d0,window_l
  66.  
  67.         cmp.l   #'kill',dummyinput
  68.         bne.s   nokill
  69.  
  70. ; This code tries to remove Xoper from the System
  71. ; in case Xoper 'freezes' or crashes.
  72. ; It works as follows: Xoper leaves the address of its cleanup
  73. ; routine in the UserData field of its Task structure. EXEC's
  74. ; context-restore code leaves the current PC of a task in the
  75. ; first longword of the tasks stack. All we have to do is to
  76. ; copy the address of Xoper's cleanup routine to its stack and
  77. ; to rescedule Xoper (using Signal() in this case).
  78.  
  79.         lea     newname,a1
  80.         move.l  sysbase,a6
  81.         jsr     _LVOFindTask(a6)
  82.         tst.l   d0
  83.         beq.s   1$
  84.         move.l  d0,a1
  85.         move.l  $58(a1),d0   ;TC_UserData: address of the Exit() routine
  86.         move.l  $36(a1),a0   ;TC_SPReg: Xoper's stackptr
  87.         move.l  d0,0(a0)     ;change Xoper's PC (first value on stack)
  88.         moveq   #-1,d0
  89.         move.l  sysbase,a6
  90.         jsr     _LVOSignal(a6)  ;force Xoper to be dispatched
  91.  
  92. 1$        moveq   #0,d0
  93.         rts
  94.  
  95. nokill        move.l  sysbase,a4
  96.         move.l  276(a4),a4
  97.         tst.l   $ac(a4)
  98.         bne.s   notwb
  99.         lea     $5c(a4),a0
  100.         CALL    WaitPort,sysbase
  101.         lea     $5c(a4),a0
  102.         CALL    GetMsg,sysbase
  103.         move.l  d0,wbmsg
  104.         move.w  #$740a,in
  105. notwb:
  106.        IFND  DEBUG
  107.         lea     xopcon,a1
  108.         CALL    FindPort,sysbase
  109.         tst.l   d0
  110.         bne     oops
  111.        ENDC
  112.         tst.l   wbmsg
  113.         beq.s   fromdos
  114.         jmp     mainprg
  115.  
  116. fromdos:
  117.  
  118. starttask:
  119.  
  120.     IFND DEBUG
  121.         cmp.w   #'-b',dummyinput
  122.         bne.s   stt1
  123.         CALL    Output,dosbase
  124.         move.l  d0,-(a7)
  125.         move.l  #windowname,d2
  126.         move.l  d0,d1
  127.         moveq.l #newname-windowname-1,d3
  128.         CALL    Write,dosbase
  129.         move.l  #cr,d2
  130.         move.l  (a7)+,d1
  131.         moveq.l #1,d3
  132.         CALL    Write,dosbase
  133. stt1        lea     start(PC),a1
  134.         move.l  -4(a1),d3
  135.         move.l  d3,myseg
  136.  
  137.         move.l  #mainprg,d3
  138.         subq    #4,d3
  139.         lsr.l   #2,d3
  140.         clr.l   -4(a1)
  141.  
  142.         move.l  4,a0
  143.         move.l  276(a0),a0
  144.         move.l  152(a0),d1
  145.         CALL    DupLock,dosbase
  146.         move.l  d0,-(a7)
  147.  
  148.         CALL    Forbid,sysbase
  149.         move.l  #newname,d1
  150.         clr.l   d2
  151.         move.l  #3500,d4
  152.         CALL    CreateProc,dosbase
  153.         move.l  d0,a0
  154.         move.l  (a7)+,d0
  155.         move.l  d0,60(a0)
  156.         CALL    Permit,sysbase
  157.  
  158.         moveq   #0,d0
  159.         rts
  160. oops        suba.l  a0,a0
  161.         CALL    DisplayBeep,intuibase
  162.         CALL    Forbid,sysbase
  163.         move.l  wbmsg,d0
  164.         beq.s   leave
  165.         move.l  d0,a1
  166.         CALL    ReplyMsg,sysbase
  167.         moveq   #0,d0
  168. leave        rts
  169.  
  170. dosname     dc.b    'dos.library',0
  171. intuiname   dc.b    'intuition.library',0
  172. gfxname     dc.b    'graphics.library',0
  173. conname     dc.b    'console.device',0
  174.         EVEN
  175.  
  176. main        CODE    xoper
  177.     ENDC
  178. mainprg     move.l  sysbase,a0
  179.         move.l  a0,_SysBase
  180.         move.l  a7,realstack
  181.         move.l  276(a0),a0          ;ExecBase->ThisTask
  182.         move.l  a0,mytask
  183.         move.l  50(a0),oldproctrap  ;original AmigaDos Trap-Handler
  184.  
  185.         move.l  #exitall,88(a0)     ;leave a message for 'KillXoper'
  186.  
  187.         move.l  #newname,10(a0)
  188.         pea     0
  189.         pea     xopcon
  190.         LIBCALL CreatePort
  191.         addq    #8,a7
  192.         move.l  d0,replyport
  193.         pea     0
  194.         pea     0
  195.         LIBCALL CreatePort
  196.         addq    #8,a7
  197.         move.l  d0,timerport
  198.         lea     timerio,a1
  199.         move.l  d0,14(a1)
  200.         move.l  d0,a2
  201.         move.b  15(a2),d0
  202.         ext.w   d0
  203.         move.w  d0,timersig
  204.         lea     timernam(PC),a0
  205.         moveq   #0,d1
  206.         moveq   #1,d0
  207.         CALL    OpenDevice,_SysBase(PC) ;open 'timer.device'
  208.  
  209. ;install a counter to determine the amount of CPU-time each
  210. ;Task uses.
  211.         move.l  _SysBase(PC),a1
  212.         move.l  #_LVOSwitch,a0
  213.         move.l  2(a1,a0),oldswitch
  214.         move.l  #myswitch,d0
  215.         CALL    SetFunction,_SysBase(PC)
  216. ;install a counter for PORT-Interrupts
  217.         lea     IOCounter(PC),a1
  218.         moveq   #3,d0
  219.         CALL    AddIntServer,_SysBase(PC)
  220.  
  221. ;Attempt to open a startup script
  222.         move.l  mytask(PC),a4      ;disable the 'please insert'
  223.         move.l  184(a4),-(a7)
  224.         move.l  #-1,184(a4)        ;requester
  225.         move.l  #startupname+2,d1  ;'Xoper.Startup'
  226.         move.l  #1005,d2
  227.         CALL    Open,dosbase(PC)
  228.         tst.l   d0
  229.         bne.s   7$
  230.         move.l  #startupname,d1    ;'S:Xoper.Startup'
  231.         move.l  #1005,d2
  232.         CALL    Open,dosbase(PC)
  233.  
  234. 7$        move.l  (a7)+,184(a4)      ;reenable the requester
  235.         move.l  d0,infile
  236.         beq.s   nostartup
  237.  
  238.         move.b  #1,fromfile
  239.  
  240. 8$        lea     dummy,a5
  241.         moveq   #-1,d5
  242. 5$        addq.l  #1,d5
  243.         move.l  infile(PC),d1
  244.         move.l  a5,d2
  245.         add.l   d5,d2
  246.         moveq.l #1,d3
  247.         CALL    Read,dosbase(PC)
  248.         tst.l   d0
  249.         bgt.s   10$
  250.  
  251.         move.l  infile(PC),d1
  252.         CALL    Close,dosbase(PC)
  253.         clr.l   infile
  254.         tst     d5
  255.         beq.s   endstartup
  256.         bra.s   9$
  257.  
  258. 10$        cmp.b   #10,0(a5,d5)
  259.         beq.s   9$
  260.         cmp.b   #13,0(a5,d5)
  261.         bne.s   5$
  262.  
  263. 9$        move.l  d5,d0
  264.         addq    #1,d0
  265.         bsr     cli            ;execute the script as if typed in
  266.         tst.l   infile
  267.         bne.s   8$
  268.  
  269. endstartup  clr.b   fromfile
  270.  
  271. nostartup   tst.l   wbmsg
  272.         bne.s   noin
  273.         cmp.b   #10,dummyinput
  274.         beq.s   noin
  275.         cmp.w   #'-b',dummyinput   ;requested as a background task ?
  276.         beq.s   noin
  277.         move.l  dummyinput,in
  278.         move.b  #10,in+4
  279.         bra.s   nostartup2
  280. noin        cmp.b   #10,in
  281.         beq.s   default
  282.         tst.b   in
  283.         bne.s   nostartup2
  284.  
  285. default     move.w  #$740a,in           ;couldn't find defaults, defaults to
  286.                        ;tasks
  287.  
  288. nostartup2  cmp.w   #'-b',dummyinput
  289.         beq     instback
  290.  
  291. ;This code just opens a Window. Position
  292. ;and size are taken from window_l,window_t,
  293. ;window_w,window_h.
  294. restart     tst.b   ownscreen
  295.         beq.s   1$
  296.         bsr     createscreen
  297.         bra.s   2$
  298. 1$        bsr     setupwindow
  299.  
  300. 2$        move.l  mytask(PC),a0
  301.         clr.l   26(a0)              ;clear 'spurious' signals
  302.  
  303.         clr.l   ptr
  304.         tst.b   gotguru
  305.  
  306.         beq.s   3$
  307.         bsr     showguru
  308.         clr.b   gotguru
  309. 3$        bra     processmsgs
  310.  
  311. ;show a list. The string entered from keyboard is stored
  312. ;in 'in'. Every character is interpreted as one command
  313. ;i.e. 'rip' means 'resources'+'interrupts'+'ports'.
  314. ;search the command to be executed. If none is found,
  315. ;show a help message
  316.  
  317. showwhat    tst.b   fromfile
  318.         bne     endshow
  319.         move.w  cmdptr(PC),d7
  320.  
  321. input        lea     in,a0
  322.         move.b  0(a0,d7.w),d0
  323.         beq     endshow
  324.         addq.b  #1,d7
  325.         cmpi.b  #' ',d0
  326.         bne.s   1$
  327.  
  328.         bsr     testifend
  329.         beq     endshow
  330.         move.w  d2,cmdptr
  331.         bra     notfinished
  332.  
  333. 1$        cmpi.b  #10,d0
  334.         beq     endshow
  335.         or.b    #32,d0
  336.         cmpi.b  #'q',d0
  337.         beq     exit
  338.         lea     params(PC),a0
  339.         moveq   #0,d1
  340. i1        cmp.b   0(a0,d1),d0
  341.         beq.s   foundp
  342.         addq.b  #1,d1
  343.         cmpi.b  #parmnum,d1
  344.         bne.s   i1
  345.  
  346.         move.l  #usetxt,d0
  347.         move.b  #1,mnflag
  348.         bsr     putnam
  349.         clr.b   mnflag
  350.         bra     endshow
  351.  
  352. foundp        lsl.b   #2,d1
  353.         lea     subs(PC),a0
  354.         move.b  #1,mnflag
  355.         jsr     0(a0,d1)
  356.         clr.b   mnflag
  357.         bsr     testifend
  358.         beq     input
  359.         bsr     newline
  360.         bra     input
  361.  
  362. testifend   lea     in,a0
  363.         lea     0(a0,d7),a0
  364.         move.w  d7,d2
  365. 2$        move.b  (a0)+,d0
  366.         beq.s   1$
  367.         cmpi.b  #' ',d0
  368.         bne.s   3$
  369.         addq    #1,d2
  370.         bra.s   2$
  371. 3$        cmpi.b  #10,d0
  372. 1$        rts
  373.  
  374.  
  375. endshow     tst.b   fromfile
  376.         bne.s   nomore
  377.         clr.w   cmdptr
  378. notfinished bsr     starttimer
  379. nomore        tst.b   fromfile
  380.         bne.s   1$
  381.         clr.l   lastprinted
  382.         bsr     blastout
  383. 1$        rts
  384.  
  385. ;get the string from inputbuffer; search and execute
  386. ;the command, if any.
  387.  
  388. cli        lea     dummy,a0
  389.         subq    #1,d0
  390. cl2        subq    #1,d0
  391.         bmi.s   cl1
  392.         cmp.b   #' ',0(a0,d0)
  393.         beq.s   cl2
  394. cl1        addq    #1,d0
  395.         move.b  #10,0(a0,d0)
  396.         bsr     kllblnks
  397.         cmpi.b  #10,0(a0)
  398.         beq     showwhat
  399.         cmpi.b  #';',0(a0)
  400.         beq     nomore
  401.  
  402.         bsr     findcmd
  403.         tst.l   d2
  404.         bpl.s   okcmd
  405.         bsr     findalias
  406.         tst.l   d2
  407.         bmi.s   nm1
  408.  
  409. okcmd        clr.b   procnum
  410.         adda.w  d1,a0
  411.         bsr     kllblnks
  412.         lsl     #2,d2
  413.         lea     cmdaddr(PC),a1
  414.         jsr     0(a1,d2)
  415.         bra     nomore
  416.  
  417. nm1        lea     in,a1
  418.         lea     buffer,a2
  419. nm2        move.b  (a1)+,(a2)+
  420.         cmp.b   #10,-1(a1)
  421.         bne.s   nm2
  422.         lea     in,a1
  423. nm0        move.b  (a0)+,(a1)+
  424.         cmp.b   #10,-1(a1)
  425.         bne.s   nm0
  426.         lea     dummy,a2
  427.         lea     buffer,a1
  428. nm3        move.b  (a1)+,(a2)+
  429.         cmp.b   #10,-1(a1)
  430.         bne.s   nm3
  431.         clr.w   cmdptr
  432.         bra     showwhat
  433.  
  434. findcmd     bsr     strbuf
  435.         move.l  a0,a5
  436.         lea     commds(PC),a2
  437.         moveq   #0,d2
  438. 1$        lea     buffer,a0
  439.         move.l  a2,a1
  440.         bsr     strcmp
  441.         beq     3$
  442. 2$        tst.b   (a2)+
  443.         bne.s   2$
  444.         addq    #1,d2
  445.         cmp.w   #cmdnum,d2
  446.         bne.s   1$
  447.         moveq   #-1,d2
  448. 3$        move.l  a5,a0
  449.         rts
  450.  
  451. findalias   move.l  a0,a5
  452.         move.l  aliaslist(PC),d4
  453. 1$        beq.s   3$
  454.         move.l  d4,a4
  455.         lea     buffer,a0
  456.         lea     5(a4),a1
  457.         move.b  4(a4),d2
  458.         ext.w   d2
  459.         ext.l   d2
  460.         bsr     strcmp
  461.         beq     4$
  462.         move.l  0(a4),d4
  463.         bra.s   1$
  464. 3$        moveq   #-1,d2
  465. 4$        move.l  a5,a0
  466.         rts
  467.  
  468. subs        bra     showtask
  469.         bra     showaddr
  470.         bra     showdevs
  471.         bra     showlibs
  472.         bra     showres
  473.         bra     showresi
  474.         bra     showmem
  475.         bra     showprt
  476.         bra     showint
  477.         bra     stack
  478.         bra     clicomm
  479. cmdaddr     bra     settime
  480.         bra     taskpri
  481.         bra     info
  482.         bra     pri
  483.         bra     flush
  484.         bra     freeze
  485.         bra     warm
  486.         bra     signal
  487.         bra     break
  488.         bra     alert
  489.         bra     lastalert
  490.         bra     instback
  491.         bra     stopall
  492.         bra     clear
  493.         bra     cancel
  494.         bra     taskports
  495.         bra     hunks
  496.         bra     devices
  497.         bra     openlib
  498.         bra     closelib
  499.         bra     currentdir
  500.         bra     cd
  501.         bra     mypri
  502.         bra     openfiles
  503.         bra     locks
  504.         bra     unlock
  505.         bra     screens
  506.         bra     windows
  507.         bra     closescreen
  508.         bra     closewindow
  509.         bra     fonts
  510.         bra     windowfonts
  511.         bra     lockdrive
  512.         bra     freedrive
  513.         bra     capture
  514.         bra     clrcold
  515.         bra     clrcool
  516.         bra     clrwarm
  517.         bra     snoop
  518.         bra     usage
  519.         bra     inphand
  520.         bra     nohead
  521.         bra     sort
  522.         bra     hide
  523.         bra     hidden
  524.         bra     setwindow
  525.         bra     cancel
  526.         bra     iconifyoff
  527.         bra     historylines
  528.         bra     historylength
  529.         bra     showhistory
  530.         bra     repeatcmd
  531.         bra     remresident
  532.         bra     saveoutput
  533.         bra     killhistory
  534.         bra     iconbackdrp
  535.         bra     setfont
  536.         bra     trapguru
  537.         bra     outputlines
  538.         bra     usescreen
  539.         bra     usewindow
  540.         bra     grabtimerio
  541.         bra     dchange
  542.         bra     alias
  543.         bra     remnode
  544.         bra     setfkey
  545.         bra     clicmd
  546.  
  547. ;------ Task-Structures-----
  548.  
  549. showaddr    clr.b   tasktyp
  550.         bra.s   startask
  551. showtask    move.b  #1,tasktyp
  552. startask    tst.b   headon
  553.         beq     noheader1
  554.         move.l  #infoh1,d0
  555.         bsr     putstr
  556.         move.l  _SysBase(PC),a6
  557.         move.l  #cpu2,d0
  558.         btst    #1,297(a6)      ;SysBase->AttnFlags
  559.         bne.s   cpupr
  560.         move.l  #cpu1,d0
  561.         btst    #0,297(a6)
  562.         bne.s   cpupr
  563.         move.l  #cpu0,d0
  564. cpupr        bsr     putstr
  565.         move.l  _SysBase(PC),a6
  566.         btst    #2,297(a6)
  567.         beq.s   no881
  568.         move.l  #cpu3,d0
  569.         bsr     putstr
  570. no881        moveq   #20,d1
  571.         bsr     tab
  572.         move.l  #infoh3,d0
  573.         bsr     putstr
  574.  
  575. noheader1   move.l  _SysBase(PC),a6
  576.         move.w  #$4000,$dff09a
  577.         move.l  280(a6),d0
  578.         move.l  284(a6),d1
  579.         move.l  oldidl,d3
  580.         move.l  d0,oldidl
  581.         sub.l   d3,d0
  582.         move.l  olddisp,d3
  583.         move.l  d1,olddisp
  584.         sub.l   d1,d3
  585.         move.l  d0,d1
  586.         sub.l   d3,d1
  587.         move.l  d1,maxdisp
  588.         move.l  d3,-(a7)
  589.         movem.l d0-d3,-(a7)
  590.         moveq   #1,d5
  591.         bsr     getaskdat
  592.         move.l  a5,savedat
  593.         movem.l (a7)+,d0-d3
  594.         sub.l   d3,d0
  595.         neg.l   d3
  596.         tst.b   headon
  597.         beq.s   noheader2
  598.         bsr     prcent
  599.         bsr     newline
  600.         move.l  #infoh2,d0
  601.         bsr     putstr
  602. noheader2   move.l  (a7)+,d0
  603.         neg.l   d0
  604.         move.l  d0,dispatches
  605.         tst.b   headon
  606.         beq     noheader3
  607.         mulu    #100,d0
  608.         move.l  d0,-(a7)
  609.  
  610.         lea     secs(PC),a0
  611.         lea     mics(PC),a1
  612.         CALL    CurrentTime,intuibase(PC)
  613.         move.l  secs(PC),d3
  614.         lsl.l   #1,d3
  615.         move.l  d3,d1
  616.         lsl.l   #2,d3
  617.         add.l   d1,d3
  618.         move.l  mics(PC),d0
  619.         move.l  #100000,d1
  620.         bsr     div
  621.         add.l   d0,d3
  622.         move.l  time10(PC),d1
  623.         move.l  d3,time10
  624.         sub.l   d1,d3
  625.         move.l  (a7)+,d0
  626.         move.l  d3,-(a7)
  627.         move.l  d3,d1
  628.         bsr     div
  629.         moveq   #1,d5
  630.         bsr     putfrac
  631.  
  632.         moveq   #20,d1
  633.         bsr     tab
  634.         move.l  #infoh7,d0
  635.         bsr     putstr
  636.         move.l  iocount(PC),d0
  637.         clr.l   iocount
  638.         mulu    #100,d0
  639.         move.l  (a7)+,d3
  640.         move.l  d3,d1
  641.         bsr     div
  642.         moveq   #1,d5
  643.         bsr     putfrac
  644.  
  645.         bsr     newline
  646.         bsr     newline
  647. noheader3   lea     theader(PC),a0
  648.         tst.b   tasktyp
  649.         bne.s   phedder
  650.         lea     t2header(PC),a0
  651. phedder     bsr     puthead
  652.         move.l  savedat(PC),a5
  653.  
  654. pt1        tst.b   entries
  655.         beq     pt2
  656.         lea     -16(a5),a5
  657.         bsr     hideit
  658.         tst     d0
  659.         beq     ptend
  660.         move.l  0(a5),a4
  661.         move.l  a4,d0
  662.         move.l  d0,node
  663.         bsr     hexa
  664.         tst.b   tasktyp
  665.         beq.s   pt12
  666.         moveq   #0,d0
  667.         move.b  8(a4),d0
  668.         bsr     gettype
  669.  
  670. pt12        moveq   #0,d0
  671.         move.b  9(a5),d0
  672.         subq.b  #1,d0
  673.         mulu    #10,d0
  674.         move.l  #status,d1
  675.         add.l   d1,d0
  676.         bsr     putstr
  677.         tst.b   tasktyp
  678.         bne.s   pt13
  679.  
  680.         move.l  18(a4),d0
  681.         bsr     hexa
  682.         move.l  #longnix,d0
  683.         cmp.b   #4,9(a5)
  684.         beq.s   pt14
  685.         bsr     putstr
  686.         bra.s   pt15
  687. pt14        move.l  22(a4),d0
  688.         bsr     hexa
  689. pt15        move.l  26(a4),d0
  690.         bsr     hexa
  691.         move.l  54(a4),a1
  692.         move.l  0(a1),d0
  693.         cmp.b   #2,9(a5)
  694.         bne.s   pt16
  695.         move.l  #*,d0
  696. pt16        bsr     hexa
  697.         bra     pt4
  698.  
  699. pt13        move.b  10(a5),d3
  700.         bsr     plusmins
  701.  
  702.         move.l  dispatches(PC),d0
  703.         tst.b   usageflag
  704.         beq.s   pt37
  705.         move.l  maxdisp(PC),d0
  706. pt37        move.l  12(a5),d3
  707.         bsr     prcent
  708.  
  709.         cmpi.b  #13,8(a5)
  710.         bne.s   noproc
  711.         tst.l   172(a4)
  712.         beq.s   noproc
  713.         move.b  11(a5),d3
  714.         bsr     bytedec
  715.         bra.s   pt4
  716. noproc        move.l  #nix,d0
  717.         bsr     putstr
  718.  
  719. pt4        bsr     gettaskname
  720.         bsr     newline
  721.  
  722. ptend        subq.b  #1,entries
  723.         bra     pt1
  724. pt2        rts
  725.  
  726. putlist     move.l  0(a4),a4
  727.         tst.l   0(a4)
  728.         beq.s   endlist
  729.         bsr     putdata
  730.         bra.s   putlist
  731. endlist     rts
  732.  
  733. putdata     move.l  a4,0(a5)
  734.         move.l  10(a4),4(a5)        ;task->ln_Name
  735.         move.b  8(a4),8(a5)         ;task->ln_Type
  736.         move.b  15(a4),9(a5)        ;task->tc_State
  737.         move.b  9(a4),10(a5)        ;task->ln_Pri
  738.         move.b  143(a4),11(a5)      ;Process->pr_Tasknum
  739.         clr.l   12(a5)
  740.         lea     cputime,a0
  741.         move.l  tasksnum(PC),d1
  742.         subq    #1,d1
  743.         bmi.s   pua1
  744. pua3        cmp.l   (a0)+,a4
  745.         dbeq    d1,pua3
  746.         tst     d1
  747.         bmi.s   pua1
  748. pua2        move.l  508(a0),12(a5)
  749. pua1        lea     16(a5),a5
  750.         addq.b  #1,entries
  751.         rts
  752.  
  753. gettype     and.l   #$f,d0
  754.         mulu    #11,d0
  755.         add.l   #type,d0
  756.         bra     putstr
  757.  
  758. getaskdat   move.w  #$4000,$dff09a
  759.         move.l  d5,-(a7)
  760.         lea     buffer,a5
  761.         clr.b   entries
  762.         lea     stplist(PC),a4
  763.         bsr     putlist
  764.         move.l  _SysBase(PC),a4
  765.         lea     420(a4),a4          ;SysBase->TaskWait
  766.         bsr     putlist
  767.         move.l  _SysBase(PC),a4
  768.         lea     406(a4),a4          ;SysBase->TaskReady
  769.         bsr     putlist
  770.         move.l  _SysBase(PC),a4
  771.         move.l  276(a4),a4          ;SysBase->ThisTask
  772.         bsr     putdata
  773.         move.l  (a7)+,d5
  774.         beq.s   1$
  775.         clr.l   tasksnum
  776. 1$        move.w  #-$4000,$dff09a
  777.         moveq   #16,d2
  778.         lea     -32(a5),a2
  779.         bsr.s   sortlist
  780.         rts
  781.  
  782. sortlist    tst.b   sorton
  783.         beq.s   sort5
  784.         lea     buffer,a3
  785. sort1        lea     0(a3,d2),a4
  786. sort2        move.l  0(a3),d1
  787.         cmp.l   0(a4),d1
  788.         bge.s   sort3
  789.         move.l  d2,d1
  790.         subq    #1,d1
  791. sort4        move.b  0(a4,d1),d0
  792.         move.b  0(a3,d1),0(a4,d1)
  793.         move.b  d0,0(a3,d1)
  794.         dbf     d1,sort4
  795. sort3        lea     0(a4,d2),a4
  796.         cmp.l   a2,a4
  797.         ble.s   sort2
  798.         lea     0(a3,d2),a3
  799.         cmp.l   a2,a3
  800.         bne.s   sort1
  801. sort5        rts
  802.  
  803. prcent        lsl.l   #1,d3
  804.         move.l  d3,d1
  805.         lsl.l   #2,d3
  806.         add.l   d1,d3
  807.         lsl.l   #2,d3
  808.         move.l  d3,d1
  809.         lsl.l   #3,d3
  810.         move.l  d3,d2
  811.         lsl.l   #1,d3
  812.         add.l   d2,d3
  813.         add.l   d1,d3
  814.         move.l  d0,d1
  815.         move.l  d3,d0
  816.         bsr     div
  817.         moveq   #0,d5
  818.         bsr     putfrac
  819.         move.l  #infoh4,d0
  820.         bra     putstr
  821.  
  822. putfrac     divu    #10,d0
  823.         move    d0,d3
  824.         swap    d0
  825.         move    d0,d1
  826.         tst     d5
  827.         bne.s   1$
  828.         cmp.w   #100,d3
  829.         ble.s   1$
  830.         move.l  #whatsthis,d0
  831.         bra     putstr
  832. 1$        bsr     bytedec
  833.         lea     out,a0
  834.         move.b  #'.',-1(a0,d0)
  835.         or.b    #'0',d1
  836.         move    d1,d0
  837.         bra     putchar
  838.  
  839. hideit        tst.b   hideon
  840.         bne.s   pt73
  841. pt75        moveq   #1,d0
  842.         rts
  843. pt73        lea     hidestart(PC),a4
  844.         move.l  4(a5),a0
  845. pt74        tst.l   0(a4)
  846.         beq.s   pt75
  847.         move.l  0(a4),a4
  848.         lea     4(a4),a1
  849.         bsr     strcmp
  850.         tst     d0
  851.         beq     hideend
  852.         bra.s   pt74
  853. hideend     rts
  854.  
  855. getaskname2 movem.l a3-a5,-(a7)
  856.         link    a2,#-10
  857.         move.l  a7,a5
  858.         move.l  d0,a4
  859.         tst.l   d0
  860.         bne.s   2$
  861.         bsr     putstr
  862.         bra.s   1$
  863. 2$        move.b  8(a4),8(a5)
  864.         move.l  10(a4),4(a5)
  865.         bsr     gettaskname
  866. 1$        unlk    a2
  867.         movem.l (a7)+,a3-a5
  868.         rts
  869.  
  870. gettaskname tst.b   cmdcli
  871.         beq.s   2$
  872.         cmpi.b  #13,8(a5)
  873.         bne.s   2$
  874.  
  875.         CALL    Forbid,_SysBase(PC)
  876.         tst.l   140(a4)             ;pr_TaskNum
  877.         beq.s   1$
  878.         move.l  172(a4),d0          ;pr_CLI
  879.         beq.s   1$
  880.         move.l  d0,a3
  881.         adda.l  a3,a3
  882.         adda.l  a3,a3
  883.         tst.l   60(a3)              ;cli_Module
  884.         beq.s   1$
  885.         move.l  #openbrak,d0
  886.         bsr     putstr
  887.         move.l  16(a3),d0           ;cli_CommandName
  888.         CALL    Permit,_SysBase(PC)
  889.         bsr     putbcpl
  890.         move.l  #closebrak,d0
  891.         bra     putstr
  892.  
  893. 1$        CALL    Permit,_SysBase(PC)
  894. 2$        move.l  4(a5),d0
  895.         bra     putstr
  896.  
  897. *-------- mem-hunks ------------
  898.  
  899. showmem     lea     mheader(PC),a0
  900.         bsr     puthead
  901.         move.l  _SysBase(PC),a5
  902.         lea     322(a5),a5          ;SysBase->MemList
  903.         moveq   #0,d5
  904. mem1        move.l  0(a5),a5            ;MemList->ln_Next
  905.         tst.l   0(a5)
  906.         beq.s   mem2
  907.         move.l  20(a5),d0           ;MemHeader->mh_Lower
  908.         bsr     hexa
  909.         move.l  24(a5),d0           ;MemHeader->mh_Upper
  910.         bsr     hexa
  911.         move.l  28(a5),d0           ;MemHeader->mh_Free
  912.         add.l   d0,d5
  913.         moveq   #1,d3
  914.         bsr     longdec
  915.         move.b  15(a5),d3           ;MemHeader->mh_Attributes
  916.         bsr     bytedec
  917.         move.b  9(a5),d3            ;MemHeader->ln_pri
  918.         bsr     plusmins
  919.         move.l  10(a5),d0           ;MemHeader->ln_Name
  920.         move.l  a5,node
  921.         bsr     putnam
  922.         bra.s   mem1
  923. mem2        move.l  #infoh6,d0
  924.         bsr     putstr
  925.         moveq   #19,d1
  926.         bsr     tab
  927.         moveq   #0,d3
  928.         move.l  d5,d0
  929.         bsr     longdec
  930. newline     move.l  #cr,d0
  931.         bra     putstr
  932.  
  933. *-------- Task-Stack ------------
  934.  
  935. stack        lea     stackhead(pc),a0
  936.         bsr     puthead
  937.         moveq   #0,d5
  938.         bsr     getaskdat
  939.  
  940. sta1        tst.b   entries
  941.         beq     sta8
  942.         lea     -16(a5),a5
  943.         bsr     hideit
  944.         tst     d0
  945.         beq     sta9
  946.         move.l  0(a5),a1
  947.         cmp.b   #13,8(a1)               ;task->ln_Type
  948.         bne.s   sta6
  949.         move.l  172(a1),d0              ;pr_CLI
  950.         beq.s   sta6
  951.         lsl.l   #2,d0
  952.         move.l  d0,a0
  953.         tst.l   60(a0)                  ;cli_Module
  954.         beq.s   sta6
  955.         moveq   #1,d3
  956.         move.l  52(a0),d4               ;cli_DefaultStack
  957.         lsl.l   #2,d4
  958.         move.l  176(a1),d0              ;pr_ReturnAddress
  959.         sub.l   d4,d0
  960.         bsr     hexa
  961.         move.l  d4,d0
  962.         bsr     longdec
  963.         move.l  176(a1),d0              ;pr_ReturnAddress
  964.         sub.l   54(a1),d0               ;tc_SPReg
  965.         bra.s   sta7
  966.  
  967. sta6        move.l  58(a1),d0               ;tc_SPLower
  968.         bsr     hexa
  969.         moveq   #1,d3
  970.         move.l  62(a1),d0               ;tc_SPUpper
  971.         sub.l   58(a1),d0               ;tc_SPLower
  972.         bsr     longdec
  973.         move.l  62(a1),d0               ;tc_SPUpper
  974.         sub.l   54(a1),d0               ;tc_SPReg
  975. sta7        bsr     longdec
  976.         move.l  a1,a4
  977.         bsr     gettaskname
  978.         bsr     newline
  979. sta9        subq.b  #1,entries
  980.         bra     sta1
  981. sta8        rts
  982.  
  983. clicomm     lea     clicomhead(pc),a0
  984.         bsr     puthead
  985.         moveq   #0,d5
  986.         bsr     getaskdat
  987. clic1        tst.b   entries
  988.         beq     clic8
  989.         lea     -16(a5),a5
  990.         bsr     hideit
  991.         tst     d0
  992.         beq     clic0
  993.         move.l  0(a5),a4
  994.         cmpi.b  #13,8(a4)               ;ln_Type
  995.         bne     clic0
  996.         tst.l   172(a4)
  997.         beq     clic0
  998.         move.l  140(a4),d3              ;pr_TaskNum
  999.         beq     clic0
  1000.         move.l  a4,d0
  1001.         move.l  d0,node
  1002.         bsr     hexa
  1003.         moveq   #0,d0
  1004.         move.b  9(a5),d0
  1005.         subq    #1,d0
  1006.         mulu    #10,d0
  1007.         move.l  #status,d1
  1008.         add.l   d1,d0
  1009.         bsr     putstr
  1010.         move.l  172(a4),a3              ;pr_CLI
  1011.         adda.l  a3,a3
  1012.         adda.l  a3,a3
  1013.         move.l  #script,d0
  1014.         tst.l   40(a3)                  ;cli_InterActive
  1015.         beq.s   clic5
  1016.         move.l  #interact,d0
  1017. clic5        bsr     putstr
  1018.         move.l  #backg,d0
  1019.         tst.l   44(a3)                  ;cli_Background
  1020.         bne.s   clic6
  1021.         move.l  #foreg,d0
  1022. clic6        bsr     putstr
  1023.         bsr     bytedec
  1024.         move.l  4(a5),d0
  1025.         bsr     putstr
  1026.         moveq   #49,d1
  1027.         bsr     tab
  1028.         move.b  #' ',d0
  1029.         bsr     putchar
  1030.         move.l  128(a4),d0              ;pr_SegList
  1031.         beq.s   noprogloadc
  1032. clic3        move.l  172(a4),d1              ;pr_CLI
  1033.         bne.s   clic4
  1034. noprogloadc move.l  #longnix,d0
  1035.         bsr     putnam
  1036.         bra.s   clic0
  1037. clic4        lsl.l   #2,d1
  1038.         move.l  d1,a4
  1039.         move.l  60(a4),d1               ;cli_Module
  1040.         beq.s   noprogloadc
  1041.         move.l  16(a4),d0               ;cli_CommandName
  1042.         bsr     putbcpl
  1043.         bsr     newline
  1044.  
  1045. clic0        subq.b  #1,entries
  1046.         bne     clic1
  1047. clic8        rts
  1048.  
  1049. *--------- interrupts ------------
  1050. showint     lea     iheader(PC),a0
  1051.         bsr     puthead
  1052.         lea     intnames(PC),a5
  1053.         lea     inttyp(PC),a4
  1054.         moveq   #0,d1
  1055.         moveq   #15,d5
  1056.         move.l  _SysBase(PC),a3
  1057.         lea     84(a3),a3           ;SysBase->IntVects[16]
  1058.  
  1059. si0        tst.b   0(a4,d1)
  1060.         bne.s   si4
  1061.         move.l  8(a3),a2            ;IntVector->iv_Node
  1062.         bra.s   si5
  1063. si4        move.l  0(a3),a2            ;Interrupt->is_Node
  1064. si5        cmp.l   #0,a2
  1065.         beq     nxtint
  1066.         tst.b   0(a4,d1)
  1067.         beq.s   si1
  1068. si2        move.l  0(a2),a2            ;is_Node->ln_Next
  1069.         tst.l   0(a2)
  1070.         beq.s   nxtint
  1071. si1        move.l  a2,d0
  1072.         move.l  d0,node
  1073.         bsr     hexa
  1074.         move.l  14(a2),d0           ;Interrupt->is_Data
  1075.         bsr     hexan
  1076.         move.l  18(a2),d0           ;Interrupt->is_Code
  1077.         bsr     hexan
  1078.         move.b  9(a2),d3            ;Interrupt->ln_Pri
  1079.         move.l  a3,-(a7)
  1080.         bsr     plusmins
  1081.         move.l  #intserv,d0
  1082.         tst.b   0(a4,d1)
  1083.         bne.s   1$
  1084.         move.l  #inthand,d0
  1085. 1$        bsr     putstr
  1086.         move.l  #intdis,d0
  1087.         move.w  $dff01c,d3
  1088.         btst.w  d1,d3
  1089.         beq.s   2$
  1090.         move.l  #inten,d0
  1091. 2$        bsr     putstr
  1092.         move.l  (a7)+,a3
  1093.         move.l  a5,d0
  1094.         bsr     putstr
  1095.         move.l  10(a2),d0           ;Interrupt->ln_Name
  1096.         bsr     putnam
  1097.         tst.b   0(a4,d1)
  1098.         bne.s   si2
  1099.         tst.l   0(a2)
  1100.         beq.s   nxtint
  1101.         move.l  0(a2),a2
  1102.         bra     si1
  1103. nxtint        addq    #1,d1
  1104.         lea     12(a5),a5
  1105.         lea     12(a3),a3
  1106.         dbf     d5,si0
  1107.         rts
  1108.  
  1109. *---------    resident ------------
  1110.  
  1111. showresi    lea     rheader(PC),a0
  1112.         bsr     puthead
  1113.         move.l  _SysBase(PC),a5
  1114.         move.l  300(a5),a5          ;SysBase->ResModules
  1115.  
  1116. r1        tst.l   0(a5)
  1117.         beq     r2
  1118.         move.l  0(a5),d0            ;Resident->ln_Next
  1119.         tst.l   d0
  1120.         bpl.s   r3
  1121.         bclr    #31,d0
  1122.         movea.l d0,a5
  1123.         bra.s   r1
  1124. r3        movea.l d0,a4
  1125.         move.l  d0,node
  1126.         bsr     hexa
  1127.         move.b  13(a4),d3           ;rt_Pri
  1128.         bsr     plusmins
  1129.         move.b  10(a4),d0           ;rt_Flags
  1130.         bsr     bin
  1131.         move.b  11(a4),d3           ;rt_Version
  1132.         bsr     bytedec
  1133.         move.b  12(a4),d0           ;rt_Type
  1134.         bsr     gettype
  1135.         move.l  14(a4),d0           ;rt_Name
  1136.         bsr     putnam
  1137. r4        addq    #4,a5
  1138.         bra     r1
  1139. r2        rts
  1140.  
  1141. *---------  ports  -------------
  1142.  
  1143. showprt     lea     pheader(PC),a0
  1144.         bsr     puthead
  1145.         move.l  _SysBase(PC),a4
  1146.         lea     392(a4),a4          ;SysBase->PortList
  1147.         lea     buffer,a5
  1148.         moveq   #0,d5
  1149.         CALL    Forbid,_SysBase(PC)
  1150.         move.w  #$4000,$dff09a
  1151. sp2        move.l  0(a4),a4            ;mp_Node.ln_Next
  1152.         tst.l   0(a4)
  1153.         beq.s   sp20
  1154.         bsr     getpdata
  1155.         bra.s   sp2
  1156. sp20        tst.b   tports
  1157.         bne.s   sp15
  1158.         move.l  _SysBase(PC),a4
  1159.         move.l  276(a4),a4          ;sysbase->ThisTask
  1160.         lea     92(a4),a4           ;process->pr_MsgPort
  1161.         bsr     getpdata
  1162.         move.l  _SysBase(PC),a2
  1163.         lea     406(a2),a2          ;sysbase->TaskReady
  1164. sp11        move.l  0(a2),a2
  1165.         tst.l   0(a2)
  1166.         beq.s   sp14
  1167.         lea     92(a2),a4           ;pr_MsgPort
  1168.         cmp.b   #13,8(a2)           ;ln_Type
  1169.         bne.s   sp11
  1170.         bsr     getpdata
  1171.         bra     sp11
  1172. sp14        move.l  _SysBase(PC),a2
  1173.         lea     420(a2),a2          ;sysbase->TaskWait
  1174. sp12        move.l  0(a2),a2
  1175.         tst.l   0(a2)
  1176.         beq.s   sp15
  1177.         lea     92(a2),a4           ;pr_MsgPort
  1178.         cmp.b   #13,8(a2)           ;ln_Type
  1179.         bne.s   sp12
  1180.         bsr     getpdata
  1181.         bra     sp12
  1182. sp15        move.w  #-$4000,$dff09a
  1183.         CALL    Permit,_SysBase(PC)
  1184.         lea     buffer,a5
  1185. sp3        tst.b   d5
  1186.         beq     sp6
  1187.         move.l  0(a5),d0
  1188.         move.l  d0,node
  1189.         bsr     hexa
  1190.         move.l  4(a5),d0
  1191.         bsr     putstr
  1192.         moveq   #25,d1
  1193.         bsr     tab
  1194.         move.b  8(a5),d0
  1195.         and.l   #3,d0
  1196.         mulu    #9,d0
  1197.         add.l   #mp_flags,d0
  1198.         bsr     putstr
  1199.         move.b  9(a5),d3
  1200.         bsr     bytedec
  1201.         move.b  14(a5),d3
  1202.         cmp.b   #255,d3
  1203.         bne.s   1$
  1204.         move.l  #toomuch,d0
  1205.         bsr     putstr
  1206.         bra.s   2$
  1207. 1$        bsr     bytedec
  1208. 2$        move.l  10(a5),d0
  1209.         bsr     getaskname2
  1210.         bsr     newline
  1211.         lea     16(a5),a5
  1212.         subq.b  #1,d5
  1213.         bra     sp3
  1214. sp6        rts
  1215.  
  1216. getpdata    move.l  a4,0(a5)
  1217.         move.l  10(a4),4(a5)        ;ln_Name
  1218.         move.b  14(a4),8(a5)        ;mp_Flags
  1219.         move.b  15(a4),9(a5)        ;mp_SigBit
  1220.         move.l  16(a4),10(a5)       ;mp_SigTask
  1221.         moveq   #0,d0
  1222.         movea.l 20(a4),a3           ;mp_MsgList
  1223. sp10        movea.l 0(a3),a3
  1224.         cmpa.l  #0,a3
  1225.         beq.s   sp9
  1226.         addq.b  #1,d0
  1227.         cmp.b   #255,d0
  1228.         bne.s   sp10
  1229. sp9        move.b  d0,14(a5)
  1230.         lea     16(a5),a5
  1231.         addq.b  #1,d5
  1232.         rts
  1233. *-------- resources ------------
  1234.  
  1235. showres     lea     lheader(PC),a0
  1236.         bsr     puthead1
  1237.         lea     resnam(PC),a0
  1238.         bsr     puthead2
  1239.         move.l  _SysBase(PC),d5
  1240.         add.l   #336,d5        ;SysBase->ResourceList
  1241.         bsr     show
  1242.         rts
  1243.  
  1244. *--------- devices  -------------
  1245.  
  1246. showdevs    lea     lheader(PC),a0
  1247.         bsr     puthead1
  1248.         lea     devnam(PC),a0
  1249.         bsr     puthead2
  1250.         move.l  _SysBase(PC),d5
  1251.         add.l   #350,d5        ;SysBase->DeviceList
  1252.         bsr     show
  1253.         rts
  1254.  
  1255. *-------- libraries -------------
  1256.  
  1257. showlibs    lea     lheader(PC),a0
  1258.         bsr     puthead1
  1259.         lea     libnam(PC),a0
  1260.         bsr     puthead2
  1261.         move.l  _SysBase(PC),d5
  1262.         add.l   #378,d5        ;SysBase->LibList
  1263.  
  1264. show        lea     buffer,a5
  1265.         clr.b   entries
  1266.         CALL    Forbid,_SysBase(PC)
  1267.         move.l  d5,a4
  1268. sl1        move.l  0(a4),a4            ;lib_Node.ln_Next
  1269.         tst.l   0(a4)
  1270.         beq.s   sl2
  1271.         addq.b  #1,entries
  1272.         move.l  a4,0(a5)
  1273.         move.l  10(a4),4(a5)        ;ln_Name
  1274.         move.b  33(a4),8(a5)        ;lib_OpenCnt
  1275.         move.b  21(a4),9(a5)        ;lib_Version
  1276.         move.b  23(a4),10(a5)       ;lib_Revision
  1277.         move.b  14(a4),11(a5)       ;lib_Flags
  1278.         lea     12(a5),a5
  1279.         bra.s   sl1
  1280. sl2        CALL    Permit,_SysBase(PC)
  1281.  
  1282.         lea     buffer,a5
  1283. dl3        tst.b   entries
  1284.         beq.s   sl4
  1285.         move.l  0(a5),d0
  1286.         move.l  d0,node
  1287.         bsr     hexa
  1288.         move.b  8(a5),d3
  1289.         bsr     bytedec
  1290.         move.b  9(a5),d3
  1291.         bsr     bytedec
  1292.         move.b  10(a5),d3
  1293.         bsr     bytedec
  1294.         move.b  11(a5),d0
  1295.         bsr     bin
  1296.         move.l  4(a5),d0
  1297.         bsr     putnam
  1298.         lea     12(a5),a5
  1299.         subq.b  #1,entries
  1300.         bra.s   dl3
  1301. sl4        rts
  1302.  
  1303. ;Remove a resident module from the list. Clears the rt_Matchword
  1304. ;to avoid being found and reinserted during the next reset
  1305. remresident bsr     nodenam2
  1306.         cmp.b   #'$',0(a5)
  1307.         bne.s   1$
  1308.         move.l  a5,a0
  1309.         bsr     readhex
  1310.         tst.b   d7
  1311.         bne.s   2$
  1312. 1$        move.l  a5,a1
  1313.         CALL    FindResident,_SysBase(PC)
  1314.         tst.l   d0
  1315.         beq     fn5
  1316.  
  1317. 2$        move.l  _SysBase(PC),a3
  1318.         move.l  300(a3),a3          ;SysBase->ResModules
  1319.  
  1320. 8$        move.l  (a3)+,d1
  1321.         beq     fn5
  1322.         bpl.s   3$
  1323.         bclr    #31,d1
  1324.         movea.l d1,a3
  1325.         bra.s   8$
  1326. 3$        cmp.l   d1,d0
  1327.         bne.s   8$
  1328.  
  1329. 4$        move.l  a3,a4
  1330. 5$        tst.l   (a4)+
  1331.         bgt.s   5$
  1332.  
  1333. 6$        move.l  d0,a1
  1334.         clr.w   0(a1)               ;rt_MatchTag
  1335.         move.l  a4,d0
  1336.         sub.l   a3,d0
  1337.         lsr     #2,d0
  1338.         subq    #1,d0
  1339.         lea     -4(a3),a1
  1340. 7$        move.l  (a3)+,(a1)+
  1341.         dbf     d0,7$
  1342.         rts
  1343.  
  1344. ;find the first entry in the device-list
  1345. ;returns a1 = pointer to first entry
  1346.  
  1347. devinfo     move.l  dosbase(PC),a1
  1348.         move.l  34(a1),a1
  1349.         move.l  24(a1),a1
  1350.         adda.l  a1,a1
  1351.         adda.l  a1,a1
  1352.         move.l  4(a1),a1
  1353.         rts
  1354.  
  1355. ;unlock a file
  1356. unlock        tst.b   fromfile
  1357.         bne     ul6
  1358.         bsr     readhex
  1359.         tst.b   d7
  1360.         beq     syntax
  1361.         move.l  d0,remembr
  1362.         move.l  d0,-(a7)
  1363.         moveq   #-1,d6
  1364.         bsr     of44
  1365.         tst.l   remembr
  1366.         beq.s   ul1
  1367.         move.l  #unlerr,d0
  1368.         bsr     putnam
  1369.         bra     ul4
  1370. ul1        bsr     ResumeOutput
  1371.         move.l  #unl1,d0
  1372.         bsr     putstr
  1373.         move.l  0(a7),d0
  1374.         bsr     getpath
  1375.         move.l  #unltxt2,d0
  1376.         bsr     putstr
  1377.         bsr     readline
  1378.         ori.b   #$20,inputbuffer
  1379.         cmp.b   #'y',inputbuffer
  1380.         bne.s   ul5
  1381.         move.l  0(a7),d1
  1382.         CALL    UnLock,dosbase
  1383. ul5        bsr     freefinfo
  1384. ul4        addq    #4,a7
  1385. ul6        rts
  1386. ;---------- Show all Locks------------
  1387. locks        moveq   #0,d6
  1388.         bra.s   of33
  1389.  
  1390. ;---------- Open Files-----------
  1391. openfiles   moveq   #1,d6
  1392. of33        move.l  mytask(PC),a4
  1393.         move.l  184(a4),inputbuffer
  1394.         move.l  #-1,184(a4)
  1395.         lea     ofheader(PC),a0
  1396.         bsr     puthead
  1397. of44        bsr     allocfinfo
  1398.         bsr     devinfo
  1399.         move.l  a1,a3
  1400. of1        adda.l  a3,a3
  1401.         adda.l  a3,a3
  1402.         cmp.l   #2,4(a3)
  1403.         bne     of2
  1404.         move.l  40(a3),d0
  1405.         lsl.l   #2,d0
  1406.         move.l  d0,a4
  1407.         moveq   #0,d3
  1408.         move.b  (a4)+,d3
  1409.         subq    #1,d3
  1410.         lea     buffer,a5
  1411. of22        move.b  (a4)+,(a5)+
  1412.         dbf     d3,of22
  1413.         move.b  #':',(a5)+
  1414.         clr.b   0(a5)
  1415.         cmp.l   #'RAM ',buffer
  1416.         bne.s   of5
  1417.         cmp.l   #'Disk',buffer+4
  1418.         bne.s   of5
  1419.         move.l  #$4d3a0000,buffer+2
  1420. of5        move.l  #buffer,d1
  1421.         move.l  #-2,d2
  1422.         CALL    Lock,dosbase(PC)
  1423.         tst.l   d0
  1424.         bne.s   of6
  1425.         move.l  #buffer,d0
  1426.         bsr     putstr
  1427.         move.l  #nomount,d0
  1428.         bsr     putnam
  1429.         bra     of2
  1430.  
  1431. of6        move.l  d0,-(a7)
  1432.         lsl.l   #2,d0
  1433.         move.l  d0,a5
  1434. of4        move.l  0(a5),d0
  1435.         cmp.l   #50,d0
  1436.         ble     of3
  1437.         move.l  d0,d5
  1438.         lsl.l   #2,d5
  1439.         move.l  d5,a5
  1440.         move.l  d0,d5
  1441.         tst     d6
  1442.         bpl.s   of45
  1443.  
  1444.         cmp.l   remembr(PC),d0
  1445.         bne.s   of4
  1446.         clr.l   remembr
  1447.         move.l  (a7)+,d1
  1448.         CALL    UnLock,dosbase(PC)
  1449.         bra     quitof
  1450.  
  1451. of45        move.l  8(a5),d4
  1452.         bsr     getfinfo
  1453.         move.l  finfoptr,a4
  1454.  
  1455.         tst.l   d6
  1456.         beq.s   of8
  1457.         bmi.s   of8
  1458.         tst.l   4(a4)
  1459.         bpl     of4
  1460. of8        move.l  d5,d0
  1461.         move.l  d0,node
  1462.         bsr     hexa
  1463.         move.l  #access,d0
  1464.         cmp     #-2,d4
  1465.         beq.s   of7
  1466.         addq    #8,d0
  1467. of7        bsr     putstr
  1468.         tst.l   4(a4)
  1469.         bmi.s   of9
  1470.         move.l  #longnix,d0
  1471.         bsr     putstr
  1472.         bra     of10
  1473. of9        move.l  124(a4),d0
  1474.         bsr     longdec
  1475. of10        move.l  d5,d0
  1476.         bsr     getpath
  1477.         bra     of4
  1478.  
  1479.         bsr     newline
  1480. of3        move.l  (a7)+,d1
  1481.         CALL    UnLock,dosbase(PC)
  1482. of2        move.l  0(a3),a3
  1483.         cmpa.l  #0,a3
  1484.         bne     of1
  1485.         bsr     freefinfo
  1486. quitof        move.l  mytask(PC),a4
  1487.         move.l  inputbuffer,184(a4)
  1488.         rts
  1489.  
  1490. ;---------- Dos Devices ----------
  1491.  
  1492. devices     lea     ddheader(PC),a0
  1493.         bsr     puthead
  1494.         bsr     devinfo
  1495. dev1        adda.l  a1,a1
  1496.         adda.l  a1,a1
  1497.         clr.b   d6
  1498.         tst.l   4(a1)
  1499.         bne     dev2
  1500.         move.l  40(a1),d0
  1501.         bsr     putbcpl
  1502.         moveq   #10,d1
  1503.         bsr     tab
  1504.         cmp.l   #20,28(a1)
  1505.         ble     dev9
  1506.         moveq   #1,d6
  1507.         move.l  28(a1),a3
  1508.         adda.l  a3,a3
  1509.         adda.l  a3,a3
  1510.         cmp.l   #20,8(a3)
  1511.         ble     dev9
  1512.         move.l  8(a3),a2
  1513.         adda.l  a2,a2
  1514.         adda.l  a2,a2
  1515.         move.l  12(a2),d3
  1516.         movem.l a1-a3,-(a7)
  1517.         bsr     bytedec
  1518.         movem.l (a7)+,a1-a3
  1519.         moveq   #1,d3
  1520.         move.l  20(a2),d0
  1521.         bsr     longdec
  1522.         move.l  40(a2),d0
  1523.         beq.s   devs20
  1524.         addq    #1,d0
  1525.         sub.l   36(a2),d0
  1526. devs20        bsr     longdec
  1527.         move.l  44(a2),d0
  1528.         bsr     longdec
  1529.         bra.s   dev8
  1530. dev9        move.l  #notfile,d0
  1531.         bsr     putstr
  1532. dev8        tst.l   8(a1)
  1533.         beq.s   dev6
  1534.         move.l  #devload,d0
  1535.         bra.s   dev5
  1536. dev6        move.l  #devnload,d0
  1537. dev5        bsr     putstr
  1538.         tst.b   d6
  1539.         beq.s   dev7
  1540.         move.l  4(a3),d0
  1541.         bne.s   dev4
  1542. dev7        move.l  16(a1),d0
  1543.         bne.s   dev4
  1544.         tst.l   8(a1)
  1545.         beq.s   dev11
  1546.         move.l  8(a1),a3
  1547.         move.l  -82(a3),d0
  1548.         bsr     putstr
  1549.         bra     dev11
  1550. dev4        bsr     putbcpl
  1551. dev11        bsr     newline
  1552. dev2        move.l  0(a1),a1
  1553.         cmpa.l  #0,a1
  1554.         bne     dev1
  1555.         rts
  1556.  
  1557. ; Check if a named dos-device is mounted
  1558. ; name in 'buffer'.
  1559. ; Result: d0 = 0(false) anything else(true).
  1560.  
  1561. finddev     bsr     devinfo
  1562. fdev1        adda.l  a1,a1
  1563.         adda.l  a1,a1
  1564.         clr.b   d6
  1565.         tst.l   4(a1)
  1566.         bne.s   fdev2
  1567.         move.l  40(a1),a2
  1568.         lea     buffer,a0
  1569.         bsr     strbcmp
  1570.         tst     d0
  1571.         bne.s   fdev3
  1572. fdev2        move.l  0(a1),a1
  1573.         cmpa.l  #0,a1
  1574.         bne.s   fdev1
  1575. fdev3        rts
  1576.  
  1577. ; Re-assign a drive to dos
  1578.  
  1579. freedrive   clr.l   dp_Arg1
  1580.         bra     ldr3
  1581.  
  1582. ; Inhibit a disk drive
  1583.  
  1584. lockdrive   move.l  #1,dp_Arg1
  1585. ldr3        bsr     getstr
  1586.         bsr     finddev
  1587.         bne.s   ldr1
  1588. ldr2        move.l  #buffer,d0
  1589.         bsr     putstr
  1590.         move.l  #nomount,d0
  1591.         bsr     putstr
  1592.         move.l  #dishelp,d0
  1593.         bra     putnam
  1594. ldr1        move.l  #buffer,d1
  1595.         CALL    DeviceProc,dosbase(PC)
  1596.         tst.l   d0
  1597.         beq.s   ldr2
  1598.         move.l  d0,a0
  1599.         move.l  #31,dp_Type
  1600.         bra     cons1
  1601.  
  1602. ;display the current directory of all processes,
  1603. ;except Workbench.(Worbench pr_CurrentDir is not a lock)
  1604.  
  1605. currentdir  lea     wbname(PC),a1
  1606.         CALL    FindTask,_SysBase(PC)
  1607.         move.l  d0,wbaddr
  1608.         lea     cdheader(PC),a0
  1609.         bsr     puthead
  1610.         bsr     allocfinfo
  1611.         moveq   #0,d5
  1612.         bsr     getaskdat
  1613.         lea     buffer,a5
  1614. cd2        tst.b   entries
  1615.         beq.s   cd6
  1616.         cmp.b   #13,8(a5)
  1617.         bne.s   cd5
  1618.         move.l  wbaddr(PC),d0
  1619.         cmp.l   0(a5),d0
  1620.         beq.s   cd5
  1621.         move.l  0(a5),a4
  1622.         bsr     gettaskname
  1623.         moveq   #15,d1
  1624.         bsr     tab
  1625.         move.l  0(a5),a4
  1626.         move.l  152(a4),d0
  1627. cd1        bsr     getpath
  1628. cd5        subq.b  #1,entries
  1629.         lea     16(a5),a5
  1630.         bra.s   cd2
  1631. cd6        bsr     freefinfo
  1632.         rts
  1633.  
  1634. ;Change the current directory setting of a process
  1635.  
  1636. cd        tst.b   fromfile
  1637.         bne     cd10
  1638.         move.l  a0,-(a7)
  1639.         lea     wbname(PC),a1
  1640.         CALL    FindTask,_SysBase(PC)
  1641.         move.l  d0,wbaddr
  1642.         move.l  (a7)+,a0
  1643.         bsr     getstr
  1644.         move.l  a0,-(a7)
  1645.         move.l  #buffer,d1
  1646.         move.l  #-2,d2
  1647.         CALL    Lock,dosbase(PC)
  1648.         move.l  (a7)+,a0
  1649.         tst.l   d0
  1650.         bne     cd16
  1651.         move.l  #dnotf,d0
  1652.         bra     putnam
  1653. cd16        move.l  d0,remembr
  1654.         move.l  a0,-(a7)
  1655.         bsr     allocfinfo
  1656.         move.l  remembr(PC),d0
  1657.         bsr     getfinfo
  1658.         move.l  finfoptr,a5
  1659.         move.l  (a7)+,a0
  1660.         tst.l   4(a5)
  1661.         bpl.s   cd11
  1662.         move.l  #notdir,d0
  1663.         bsr     putnam
  1664.         bra     cd18
  1665. cd11        bsr     nodenam
  1666.         moveq.l #2,d7
  1667.         lea     TRuNode(PC),a4
  1668.         bsr     findnam
  1669.         tst.b   d7
  1670.         beq.s   cd15
  1671.         move.l  d0,a5
  1672.         cmp.b   #13,8(a5)
  1673.         beq.s   cd15
  1674.         bsr     syntax
  1675.         bra     cd18
  1676. cd15        cmp.l   wbaddr,d0
  1677.         bne.s   cd13
  1678.         move.l  #wberr,d0
  1679.         bsr     putnam
  1680.         bra     cd12
  1681. cd13        move.l  152(a5),d1
  1682.         move.l  remembr,152(a5)
  1683.         move.l  d1,remembr
  1684. cd12        tst.l   remembr
  1685.         beq.s   cd14
  1686.         bsr     ResumeOutput
  1687.         move.l  #unltxt,d0
  1688.         bsr     putstr
  1689.         move.l  remembr(PC),d0
  1690.         bsr     getpath
  1691.         move.l  #unltxt2,d0
  1692.         bsr     putstr
  1693.         bsr     readline
  1694.         ori.b   #$20,inputbuffer
  1695.         cmp.b   #'y',inputbuffer
  1696.         bne.s   cd14
  1697. cd18        move.l  remembr(PC),d1
  1698.         beq.s   cd14
  1699.         CALL    UnLock,dosbase(PC)
  1700. cd14        bsr     freefinfo
  1701. cd10        rts
  1702.  
  1703. ;Display the list of inputhandlers. It adds a dummy
  1704. ;input handler, grabs the list header, and removes the handler
  1705.  
  1706. inphand     tst.b   background
  1707.         bne.s   inph1
  1708.         bsr     installh
  1709. inph1        move.l  #500,d4
  1710.         lea     InInterrupt(PC),a0
  1711. inph2        tst.l   4(a0)
  1712.         beq.s   inph3
  1713.         move.l  4(a0),a0
  1714.         dbf     d4,inph2
  1715. inph3        tst.b   background
  1716.         bne.s   inph4
  1717.         movem.l d4/a0,-(a7)
  1718.         bsr     removeh
  1719.         movem.l (a7)+,d4/a0
  1720. inph4        cmp.w   #-1,d4
  1721.         bne.s   inph5
  1722.         move.l  #failed,d0
  1723.         bra     putnam
  1724. inph5        move.l  a0,-(a7)
  1725.         lea     inheader(PC),a0
  1726.         bsr     puthead
  1727.         move.l  (a7)+,a5
  1728. inph6        move.l  0(a5),a5
  1729.         tst.l   0(a5)
  1730.         beq.s   inph7
  1731.         move.l  a5,d0
  1732.         move.l  d0,node
  1733.         bsr     hexa
  1734.         move.l  14(a5),d0
  1735.         bsr     hexa
  1736.         move.l  18(a5),d0
  1737.         bsr     hexa
  1738.         move.b  9(a5),d3
  1739.         bsr     plusmins
  1740.         move.l  10(a5),d0
  1741. inph8        bsr     putnam
  1742.  
  1743.         bra.s   inph6
  1744. inph7        rts
  1745.  
  1746. ;get all screen pointers.
  1747. ;result: d5=number of screens
  1748. ;     buffer+100 holds pointers.
  1749.  
  1750. getscr        lea     scrheader(PC),a0
  1751.         bsr     puthead
  1752. getscr2     move.l  intuibase(PC),a2
  1753.         move.l  60(a2),a2
  1754.         lea     buffer+100,a1
  1755.         move.w  #$4000,$dff09a
  1756.         moveq   #0,d5
  1757. sr1        move.l  a2,(a1)+
  1758.         move.l  0(a2),a2
  1759.         addq.l  #1,d5
  1760.         cmpa.l  #0,a2
  1761.         bne.s   sr1
  1762.         subq    #1,d5
  1763.         move.w  #-$4000,$dff09a
  1764.         rts
  1765.  
  1766. ;display screen addresses and titles
  1767.  
  1768. screens     bsr     getscr
  1769.         moveq   #1,d6
  1770.         lea     buffer+100,a1
  1771. sr2        move    d6,d3
  1772.         bsr     bytedec
  1773.         move.l  0(a1),d0
  1774.         move.l  d0,node
  1775.         bsr     hexa
  1776.         move.l  (a1)+,a2
  1777.         move.l  22(a2),d0
  1778.         bsr     putnam
  1779.         addq    #1,d6
  1780.         dbf     d5,sr2
  1781.         rts
  1782.  
  1783. ;display window addresses and titles
  1784.  
  1785. windows     clr.b   bool
  1786. windows1    bsr     getscr2
  1787.         move.l  d5,-(a7)
  1788.         lea     wnheader(PC),a0
  1789.         bsr     puthead
  1790.         move.l  (a7)+,d5
  1791.         tst.b   bool
  1792.         beq.s   wn20
  1793.         move.l  d5,-(a7)
  1794.         lea     fohead(PC),a0
  1795.         bsr     puthead
  1796.         move.l  (a7)+,d5
  1797. wn20        lea     buffer+100,a4
  1798. wn2        move.l  #onscr,d0
  1799.         bsr     putstr
  1800.         move.l  (a4)+,a2
  1801.         move.l  22(a2),d0
  1802.         bsr     putnam
  1803.         move.l  4(a2),a1
  1804. wn1        cmpa.l  #0,a1
  1805.         beq.s   wn3
  1806.         move.l  a1,d0
  1807.         move.l  d0,node
  1808.         bsr     hexa
  1809.  
  1810.         move.l  86(a1),d0          ;wn->UserPort
  1811.         beq.s   1$
  1812.         move.l  d0,a0
  1813.         move.l  16(a0),d0          ;SigTask
  1814. 1$        bsr     getaskname2
  1815.         moveq   #20,d1
  1816.         bsr     tab
  1817.         moveq   #' ',d0
  1818.         bsr     putchar
  1819.  
  1820.         move.l  32(a1),d0
  1821.         bsr     putnam
  1822.  
  1823.         tst.b   bool
  1824.         beq.s   wn21
  1825.         move.l  a1,-(a7)
  1826.         move.l  50(a1),a1
  1827.         move.l  52(a1),a1
  1828.         bsr     fontdata
  1829.         move.l  (a7)+,a1
  1830.  
  1831. wn21        move.l  0(a1),a1
  1832.         bra.s   wn1
  1833. wn3        dbf     d5,wn2
  1834.         rts
  1835.  
  1836. ;close a specified screen
  1837.  
  1838. closescreen bsr     getscr2
  1839.         moveq   #1,d6
  1840.         cmp.b   #'$',0(a0)
  1841.         bne.s   cs1
  1842.         bsr     readhex
  1843.         tst     d7
  1844.         beq     syntax
  1845.         move.l  d0,d4
  1846. csin        moveq   #0,d6
  1847. cs1        lea     buffer+100,a2
  1848. cs5        tst     d6
  1849.         bne.s   cs2
  1850.         cmp.l   (a2)+,d4
  1851.         beq.s   cs3
  1852.         bra.s   cs4
  1853. cs2        move.l  (a2)+,a1
  1854.         move.l  22(a1),a1
  1855.         bsr     strcmp
  1856.         tst     d0
  1857.         beq.s   cs3
  1858. cs4        dbf     d5,cs5
  1859.         move.l  #scnofound,d0
  1860.         bra     putnam
  1861. cs3        move.l  -4(a2),a0
  1862.         CALL    CloseScreen,intuibase(PC)
  1863.         rts
  1864.  
  1865. ;close a specified window
  1866. closewindow bsr     getwnptr
  1867. clw        move.l  a4,d0
  1868.         beq.s   cwend
  1869. cw3        tst.l   36(a4)
  1870.         beq.s   cw8
  1871.         move.l  36(a4),a0
  1872.         move.w  28(a0),d0
  1873.         and.w   #$4000,d0
  1874.         beq.s   cw9
  1875.         move.l  a4,a0
  1876.         CALL    FreeSysRequest,intuibase(PC)
  1877.         rts
  1878. cw9        move.l  a4,a1
  1879.         CALL    EndRequest,intuibase(PC)
  1880.         bra.s   cw3
  1881. cw8        move.l  a4,a0
  1882.         moveq   #0,d0
  1883.         CALL    ModifyIDCMP,intuibase(PC)
  1884.         move.l  a4,a0
  1885.         CALL    CloseWindow,intuibase(PC)
  1886. cwend        rts
  1887.  
  1888.  
  1889. getwnptr    bsr     getscr2
  1890.         moveq   #1,d6
  1891.         cmp.b   #'$',0(a0)
  1892.         bne.s   cw1
  1893.         bsr     readhex
  1894.         tst     d7
  1895.         bne.s   cwin
  1896.         bsr     syntax
  1897.         bra.s   cwerr
  1898. cwin        move.l  d0,d4
  1899.         moveq   #0,d6
  1900. cw1        lea     buffer+100,a2
  1901. cw5        move.l  (a2)+,a4
  1902.         move.l  4(a4),a4
  1903. cw6        cmpa.l  #0,a4
  1904.         beq.s   cw4
  1905.         tst     d6
  1906.         bne.s   cw2
  1907.         cmp.l   a4,d4
  1908.         beq.s   cw10
  1909.         bra.s   cw7
  1910. cw2        move.l  32(a4),a1
  1911.         bsr     strcmp
  1912.         tst     d0
  1913.         beq.s   cw10
  1914. cw7        move.l  0(a4),a4
  1915.         bra.s   cw6
  1916. cw4        dbf     d5,cw5
  1917.         move.l  #winnofound,d0
  1918.         bsr     putnam
  1919. cwerr        suba.l  a4,a4
  1920. cw10        rts
  1921.  
  1922. windowoff   movem.l d1-d7/a0-a6,-(a7)
  1923.         bsr     getscr2
  1924.         bsr     cwin
  1925.         move.l  a4,d1
  1926.         beq.s   woff1
  1927.         bsr     clw
  1928.         move.l  -(a2),a0
  1929.         move.l  a0,d4
  1930.         tst.l   4(a0)
  1931.         bne.s   woff1
  1932.         bsr     getscr2
  1933.         bsr     csin
  1934. woff1        movem.l (a7)+,d1-d7/a0-a6
  1935.         rts
  1936.  
  1937. closetskwin movem.l d1-d7/a0-a6,-(a7)
  1938. ctw0        bsr     getscr2
  1939.         lea     buffer+100,a2
  1940. ctw1        move.l  (a2)+,a4
  1941.         move.l  4(a4),a4
  1942. ctw6        cmpa.l  #0,a4
  1943.         beq.s   ctw4
  1944.         move.l  86(a4),a0
  1945.         move.l  16(a0),d1
  1946.         cmp.l   d0,d1
  1947.         bne.s   ctw7
  1948.         move.l  d0,d1
  1949.         move.l  a4,d0
  1950.         bsr     windowoff
  1951.         move.l  d1,d0
  1952.         bra     ctw0
  1953. ctw7        move.l  0(a4),a4
  1954.         bra.s   ctw6
  1955. ctw4        dbf     d5,ctw1
  1956.         movem.l (a7)+,d1-d7/a0-a6
  1957.         rts
  1958.  
  1959. ;Change the font from a specified Window
  1960.  
  1961. setfont     bsr     nodenam
  1962.         tst.b   0(a5)
  1963.         beq     syntax
  1964.         move.l  a5,a4
  1965. 1$        cmp.b   #33,(a4)+
  1966.         bge.s   1$
  1967.         tst.b   -1(a4)
  1968.         beq     syntax
  1969.         clr.b   -1(a4)
  1970.  
  1971.         lea     dummy,a0
  1972.         move.l  a5,0(a0)
  1973.         move.b  procnum(PC),d0
  1974.         ext.w   d0
  1975.         move.w  d0,4(a0)
  1976.         clr.w   6(a0)
  1977.         CALL    OpenFont,gfxbase(PC)
  1978.         tst.l   d0
  1979.         bne.s   2$
  1980.         lea     diskfont(PC),a1
  1981.         CALL    OpenLibrary,_SysBase(PC)
  1982.         move.l  d0,d5
  1983.         beq.s   4$
  1984.         move.l  d0,a6
  1985.         lea     dummy,a0
  1986.         XREF    _LVOOpenDiskFont
  1987.         jsr     _LVOOpenDiskFont(a6)
  1988.         move.l  d0,d4
  1989.         move.l  d5,a1
  1990.         CALL    CloseLibrary,_SysBase(PC)
  1991.         move.l  d4,d0
  1992.         bne.s   2$
  1993. 4$        move.l  #fonterr,d0
  1994.         bsr     putstr
  1995.         move.l  dummy,d0
  1996.         bra     putnam
  1997. 2$        move.l  d0,-(a7)
  1998.         move.l  a4,a0
  1999.         bsr     kllblnks
  2000.         bsr     getwnptr
  2001.         move.l  (a7)+,a0
  2002.         move.l  a4,d1
  2003.         bne.s   5$
  2004.         move.l  a0,a1
  2005.         CALL    CloseFont,gfxbase(PC)
  2006.         bra.s   3$
  2007. 5$        move.l  50(a4),a1
  2008.         CALL    SetFont,gfxbase(PC)
  2009.         move.l  a4,a0
  2010.         CALL    RefreshWindowFrame,intuibase(PC)
  2011. 3$        rts
  2012.  
  2013.  
  2014. ;display windows and associated fonts
  2015.  
  2016. windowfonts move.b  #1,bool
  2017.         bra     windows1
  2018.  
  2019. ;display loaded font names and definitions
  2020.  
  2021. fonts        lea     fohead(PC),a0
  2022.         bsr     puthead
  2023.         move.l  gfxbase(PC),a1
  2024.         move.l  $8c(a1),a1
  2025. fo1        tst.l   0(a1)
  2026.         beq.s   fo3
  2027.         bsr     fontdata
  2028.         move.l  0(a1),a1
  2029.         bra     fo1
  2030. fo3        rts
  2031.  
  2032. fontdata    move.l  a1,d0
  2033.         move.l  d0,node
  2034.         bsr     hexa
  2035.         move.w  30(a1),d3
  2036.         bsr     bytedec
  2037.         move.w  20(a1),d3
  2038.         bsr     bytedec
  2039.         move.w  24(a1),d3
  2040.         bsr     bytedec
  2041.         move.l  #romfnt,d0
  2042.         btst    #1,23(a1)
  2043.         beq.s   fod1
  2044.         move.l  #diskfnt,d0
  2045. fod1        bsr     putstr
  2046.         move.b  32(a1),d3
  2047.         bsr     bytedec
  2048.         move.b  33(a1),d3
  2049.         bsr     bytedec
  2050.         move.l  10(a1),d0
  2051.         bra     putnam
  2052.  
  2053. ;set update rate
  2054.  
  2055. settime     bsr     getfrac
  2056.         tst.b   d7
  2057.         bne.s   st1
  2058.         move.l  #whattime,d0
  2059.         bsr     putstr
  2060.         move.l  timeoutm(PC),d0
  2061.         move.l  #100000,d1
  2062.         bsr     div
  2063.         moveq   #0,d1
  2064.         move.b  timeout(PC),d1
  2065.         mulu    #10,d1
  2066.         add.l   d1,d0
  2067.         bne.s   1$
  2068.         move.l  #timenotset,d0
  2069.         bra     putnam
  2070. 1$        bsr     putfrac
  2071.         bra     newline
  2072.  
  2073. st1        divs    #10,d2
  2074.         move.b  d2,timeout
  2075.         swap    d2
  2076.         ext.l   d2
  2077.         moveq   #0,d3
  2078.         subq    #1,d2
  2079.         bmi.s   1$
  2080. 2$        add.l   #100000,d3
  2081.         dbf     d2,2$
  2082. 1$        move.l  d3,timeoutm
  2083.         rts
  2084. syntax        move.l  #synerr,d0
  2085. sy1        bra     putnam
  2086.  
  2087. ;copy a string from input to 'buffer'
  2088. ;a0 = pointer to string
  2089.  
  2090. getstr        lea     buffer,a5
  2091. gst2        cmp.b   #' ',0(a0)
  2092.         beq.s   gst1
  2093.         cmp.b   #10,0(a0)
  2094.         beq.s   gst1
  2095.         move.b  (a0)+,(a5)+
  2096.         bra.s   gst2
  2097. gst1        clr.b   0(a5)
  2098.         bra     kllblnks
  2099.  
  2100. ;read in a nodename or a processname
  2101.  
  2102. nodenam     bsr     isdec
  2103.         move.b  d2,procnum
  2104. nodenam2    bsr     kllblnks
  2105.         move.l  a0,a5
  2106. gno1        cmp.b   #10,(a0)+
  2107.         bne.s   gno1
  2108.         move.b  #0,-1(a0)
  2109.         rts
  2110.  
  2111. ;modify a task's priority
  2112.  
  2113. taskpri     bsr     getnum
  2114.         tst.b   d7
  2115.         beq     syntax
  2116.         move.b  d2,newpri
  2117.         bsr     nodenam
  2118.         moveq.l #2,d7
  2119.         lea     TRuNode(PC),a4
  2120.         bsr     findnam
  2121.         tst.b   d7
  2122.         beq.s   tp1
  2123.         move.l  d0,a1
  2124.         move.b  newpri,d0
  2125.         CALL    SetTaskPri,_SysBase(PC)
  2126. tp1        rts
  2127.  
  2128. ;set the priority of our task
  2129.  
  2130. mypri        bsr     getnum
  2131.         tst.b   d7
  2132.         beq     syntax
  2133.         move.l  _SysBase(PC),a1
  2134.         move.l  276(a1),a1
  2135.         move.l  d2,d0
  2136.         CALL    SetTaskPri,_SysBase(PC)
  2137.         rts
  2138.  
  2139. ;cancel a task or a process. The theory is quite simple:
  2140. ;(Process->ReturnAddr)-4 points to the return address on
  2141. ;the stack. Task->SPReg points to the next instruction
  2142. ;to be executed. We just need a
  2143. ; *(Task->SPReg) = *(Process->ReturnAddr-4).
  2144. ;If the process has been started from Dos (CLI) and
  2145. ;the process is doing disk I/O, the CLI will respond with
  2146. ;a GURU #87000004 (AsyncPKT=unexpected packed received).
  2147. ;Thats why the calling CLI is also canceled.
  2148.  
  2149.  
  2150. cancel        tst.b   fromfile
  2151.         beq.s   cancel1
  2152.         rts
  2153. cancel1     clr.l   remembr        ;used for CLI stdio
  2154.         clr.l   remembr2
  2155.         clr.b   bool
  2156.         bsr     nodenam
  2157. testagain   moveq.l #1,d7
  2158.         lea     TReNode(PC),a4
  2159.         bsr     findnam
  2160.         tst.b   d7
  2161.         bne.s   canok
  2162. cnerr        move.l  #stperr,d0
  2163.         bra     putnam
  2164.  
  2165. canok        move.l  d0,a1       ;d0=task
  2166.         move.l  d0,pointer
  2167.         cmp.b   #1,8(a1)       ;TASK ?
  2168.         bne.s   isproc
  2169.         CALL    RemTask,_SysBase(PC)
  2170.         move.l  pointer(PC),d0
  2171.         bra     closetskwin
  2172.  
  2173. isproc        movem.l d0-d7/a0-a6,-(a7)
  2174.         move.l  #-1,d0          ;needed for recursive killing tasks
  2175.         CALL    AllocSignal,_SysBase(PC)
  2176.         moveq   #0,d1
  2177.         bset    d0,d1
  2178.         move.l  d1,cancelbit
  2179.         move.l  d0,cancelbnum
  2180.         movem.l (a7)+,d0-d7/a0-a6
  2181.  
  2182.         moveq   #0,d5
  2183.         tst.l   $ac(a1)         ;pr_CLI
  2184.         beq.s   wascreproc
  2185.         move.l  $80(a1),a2      ;Seglist
  2186.         adda.l  a2,a2
  2187.         adda.l  a2,a2
  2188.         move.l  12(a2),d1       ;empty ?
  2189.         bne.s   wascreproc
  2190.         move.l  $ac(a1),a2      ;CommandLineInterface
  2191.         adda.l  a2,a2
  2192.         adda.l  a2,a2
  2193.         move.l  60(a2),d5       ;cli_Module
  2194.         tst.l   40(a2)          ;IsInteractive
  2195.         beq     dosreturn
  2196.         move.l  28(a2),remembr  ;yes,get Cli-Window locks
  2197.         move.l  56(a2),remembr2
  2198.         bra     dosreturn
  2199. wascreproc  tst.b   bool        ;it is not a CLI, ask what to do
  2200.         bne     unload
  2201.         move.b  #3,bool
  2202.         bsr     ResumeOutput
  2203.         move.l  #canerr0,d0     ;ask for Workbench
  2204.         bsr     putstr
  2205.         bsr     readline
  2206.         cmp.b   #'y',inputbuffer
  2207.         beq.s   andagain
  2208.         move.b  #2,bool
  2209.         bsr     ResumeOutput
  2210.         move.l  #canerr1,d0    ;ask for unload
  2211.         bsr     putstr
  2212.         bsr     readline
  2213.         cmp.b   #'y',inputbuffer
  2214.         bne.s   andagain
  2215.         move.b  #1,bool
  2216. andagain    move.l  pointer(PC),d0
  2217.         moveq.l #1,d7
  2218.         lea     TReNode(PC),a4
  2219.         bsr     tstnode
  2220.         tst     d5
  2221.         beq     cnerr
  2222.         bra     canok
  2223.  
  2224. unload        move.l  128(a1),d4 ;get Segmentlist
  2225.         beq.s   unl3
  2226.         lsl.l   #2,d4
  2227.         move.l  d4,a3
  2228.         cmp.l   #100,0(a3)
  2229.         bpl.s   ulerr
  2230.         move.l  12(a3),d4
  2231. unl3        tst.l   d4
  2232.         bne.s   unl4
  2233. ulerr        move.l  #unloaderr,d0 ;no Segments !?
  2234.         bra     putnam
  2235.  
  2236. unl4        cmp.b   #3,bool           ;Workbench Task
  2237.         bne.s   unl2
  2238.         move.l  a1,-(a7)
  2239.         moveq   #40,d0           ;build a copy of the
  2240.         move.l  #$10000,d1           ;Workbench startup-message
  2241.         CALL    AllocMem,_SysBase(PC)
  2242.         move.l  d0,startmess
  2243.         move.l  (a7)+,a1
  2244.         move.l  d0,a0
  2245.         move.b  #5,8(a0)
  2246.         move.w  #20,18(a0)
  2247.         move.l  d4,24(a0)
  2248.         move.l  a1,d0
  2249.         add.l   #92,d0
  2250.         move.l  d0,20(a0)
  2251.         movem.l a0-a1,-(a7)
  2252.         lea     wbname(PC),a1
  2253.         CALL    FindPort,_SysBase(PC)
  2254.         movem.l (a7)+,a0-a1
  2255.         move.l  d0,14(a0)
  2256.         bne.s   unl2
  2257.         move.l  #noworkbench,d0
  2258.         bra     putnam
  2259.  
  2260. unl2        cmp.b   #1,bool
  2261.         bne.s   dosreturn
  2262.         move.l  a1,-(a7)           ;unload process manualy
  2263.         move.l  d4,d1
  2264.         CALL    UnLoadSeg,dosbase(PC)
  2265.         move.l  (a7)+,a1
  2266.  
  2267. dosreturn   move.l  140(a1),savedat ;Processnumber
  2268. dosret1     move.w  #$4000,$dff09a
  2269.         move.l  54(a1),a3
  2270.         move.l  #endtask,0(a3)
  2271.         tst.b   gotguru
  2272.         bne.s   1$
  2273.         tst.b   bool
  2274.         bne.s   1$
  2275.         move.b  #2,106(a1)       ;ignore messages
  2276. 1$        cmp.b   #4,15(a1)        ;if waiting
  2277.         bne.s   doswait
  2278.         move.l  a1,d4
  2279.         CALL    Remove,_SysBase(PC)
  2280.         move.l  d4,a1
  2281.         lea     406(a6),a0       ; activate the task
  2282.         CALL    AddHead,_SysBase(PC)
  2283.         move.l  d4,a1
  2284.  
  2285. doswait     move.w  #-$4000,$dff09a
  2286.  
  2287.         tst.b   bool
  2288.         bne.s   endnodos
  2289.         tst.l   d5
  2290.         beq.s   endcanc
  2291.  
  2292.         move.l  $ac(a1),a2
  2293.         adda.l  a2,a2
  2294.         adda.l  a2,a2
  2295. dwa1        movem.l d0-d7/a0-a6,-(a7)
  2296.         move.l  cancelbit(PC),d0
  2297.         CALL    Wait,_SysBase(PC)
  2298.         movem.l (a7)+,d0-d7/a0-a6
  2299.         tst.b   gotguru
  2300.         bne.s   endnodos
  2301.         moveq   #0,d5
  2302.         bra     dosret1
  2303.  
  2304. endcanc     move.l  a1,-(a7)
  2305.         move.l  remembr(PC),d1    ;close CLI-Window
  2306.         beq.s   ecan1          ;if any
  2307.         CALL    Close,dosbase(PC)
  2308. ecan1        move.l  remembr2(PC),d1
  2309.         beq.s   ecan2
  2310.         CALL    Close,dosbase(PC)
  2311. ecan2        move.l  (a7)+,a1
  2312.  
  2313.         move.l  savedat(PC),d0   ;remove Task from
  2314.         move.l  dosbase(PC),a2   ;TaskArray
  2315.         move.l  34(a2),a2
  2316.         move.l  0(a2),a2
  2317.         adda.l  a2,a2
  2318.         adda.l  a2,a2
  2319.         lsl.l   #2,d0
  2320.         clr.l   0(a2,d0)
  2321.  
  2322. endnodos    move.l  a1,d0
  2323.         bsr     closetskwin
  2324.         move.l  cancelbnum(PC),d0      ;remove our Signal
  2325.         CALL    FreeSignal,_SysBase(PC)
  2326.         rts
  2327.  
  2328. ;This Code is (hopefully) executed by the Process we want
  2329. ;to kill
  2330.  
  2331. endtask     move.l  _SysBase(PC),a1
  2332.         move.l  276(a1),a1
  2333.         move.l  176(a1),a1          ;Process_ReturnAddr
  2334.         lea     -4(a1),a7           ;reset Process Stackptr
  2335.         tst.b   bool
  2336.         bne.s   et0
  2337.         movea.l mytask(PC),a1
  2338.         move.l  cancelbit(PC),d0    ;signal Xoper it
  2339.         CALL    Signal,_SysBase(PC) ;died
  2340. et0        cmp.b   #3,bool        ;Workbench Process ?
  2341.         bne.s   et1
  2342.         CALL    Forbid,_SysBase(PC)
  2343.         move.l  startmess(PC),a1
  2344.         CALL    ReplyMsg,_SysBase(PC) ;reply startup message
  2345. et1        rts
  2346.  
  2347. ;Stop a task (just queue it on a special list)
  2348.  
  2349. freeze        bsr     nodenam
  2350.         moveq.l #1,d7
  2351.         lea     TReNode(PC),a4
  2352.         bsr     findnam
  2353.         tst.b   d7
  2354.         bne.s   frok
  2355.         move.l  #stperr,d0
  2356.         bra     putstr
  2357. frok        move.w  #$4000,$dff09a
  2358.         move.l  d0,a1
  2359.         CALL    Remove,_SysBase(PC)
  2360.         move.w  #-$4000,$dff09a
  2361.         move.l  d0,a1
  2362.         move.l  d0,a5
  2363.         lea     stplist(PC),a0
  2364.         CALL    AddHead,_SysBase(PC)
  2365.         add.b   #4,15(a5)
  2366.         rts
  2367. ;put the task back on its list
  2368. warm        bsr     nodenam
  2369.         cmp.b   #'$',0(a5)
  2370.         bne.s   1$
  2371.         move.l  d7,d2
  2372.         move.l  a5,a0
  2373.         bsr     readhex
  2374.         tst.b   d7
  2375.         beq.s   1$
  2376.         move.l  stplist(PC),a3
  2377. 3$        tst.l   0(a3)
  2378.         beq.s   2$
  2379.         cmp.l   a3,d0
  2380.         beq.s   waok
  2381.         move.l  0(a3),a3
  2382.         bra.s   3$
  2383. 1$        lea     stplist(PC),a0
  2384.         movea.l a5,a1
  2385.         moveq   #0,d7
  2386.         bsr     fn4
  2387.         tst.b   d7
  2388.         bne.s   waok
  2389. 2$        move.l  #waerr,d0
  2390.         bra     putstr
  2391. waok        move.w  #$4000,$dff09a
  2392.         move.l  d0,a1
  2393.         CALL    Remove,_SysBase(PC)
  2394.         move.l  d0,a1
  2395.         move.l  d0,a5
  2396.         move.l  TReNode,a0
  2397.         cmp.b   #8,15(a1)
  2398.         bne.s   wa1
  2399.         move.l  TWaNode,a0
  2400. wa1        adda.l  _SysBase(PC),a0
  2401.         CALL    AddTail,_SysBase(PC)
  2402.         move.l  d0,a1
  2403.         subq.b  #4,15(a5)
  2404.         move.w  #-$4000,$dff09a
  2405.         move.l  18(a5),d0
  2406.         and.l   26(a5),d0
  2407.         beq.s   wa2
  2408.         movea.l a5,a1
  2409.         CALL    Signal,_SysBase(PC)
  2410. wa2        rts
  2411. ;show the hunks of a process
  2412. hunks        bsr     nodenam
  2413.         moveq.l #2,d7
  2414.         lea     TRuNode(PC),a4
  2415.         bsr     findnam
  2416.         tst.b   d7
  2417.         bne.s   hu1
  2418.         rts
  2419. hu1        move.l  d0,a4
  2420.         cmp.b   #13,8(a4)
  2421.         beq.s   hu2
  2422.         move.l  #noprocs,d0
  2423.         bra     putnam
  2424. hu2        move.l  128(a4),d0
  2425.         beq.s   noprogload
  2426.         lsl.l   #2,d0
  2427.         move.l  d0,a3
  2428.         move.l  12(a3),d1
  2429.         beq.s   hu3
  2430.         cmp.l   #100,0(a3)
  2431.         ble.s   1$
  2432.         move.l  #unloaderr,d0
  2433.         bra.s   huxx
  2434. 1$        move.l  #segloaded,d0
  2435.         bsr     putnam
  2436.         bra     hu5
  2437. hu3        move.l  172(a4),d1
  2438.         bne.s   hu4
  2439. noprogload  move.l  #notload,d0
  2440. huxx        bra     putnam
  2441. hu4        move.l  #cliprocs,d0
  2442.         bsr     putnam
  2443.         lsl.l   #2,d1
  2444.         move.l  d1,a4
  2445.         move.l  60(a4),d1
  2446.         beq.s   noprogload
  2447.         move.l  #procloaded,d0
  2448.         bsr     putstr
  2449.         move.l  16(a4),d0
  2450.         bsr     putbcpl
  2451.         bsr     newline
  2452. hu5        lea     hunkheader(PC),a0
  2453.         bsr     puthead
  2454.         moveq   #0,d5
  2455. hu6        move.l  d5,d3
  2456.         bsr     bytedec
  2457.         addq    #1,d5
  2458.         move.l  d1,d0
  2459.         bsr     hexa
  2460.         lsl.l   #2,d1
  2461.         move.l  d1,a4
  2462.         move.l  d1,d0
  2463.         addq.l  #4,d0
  2464.         bsr     hexa
  2465.         move.l  -4(a4),d0
  2466.         bsr     hexa
  2467.         bsr     newline
  2468.         move.l  0(a4),d1
  2469.         bne.s   hu6
  2470.         rts
  2471. ;change the priority of a node
  2472. pri        bsr     getnum
  2473.         tst.b   d7
  2474.         beq     syntax
  2475.         move.b  d2,newpri
  2476.         bsr     nodenam2
  2477.         moveq.l #5,d7
  2478.         lea     DevNode(PC),a4
  2479.         bsr     findnam
  2480.         tst.b   d7
  2481.         beq.s   pi1
  2482.         move.l  d0,a1
  2483.         move.b  newpri,9(a1)
  2484.         cmp.l   #SemNode,a4
  2485.         ble.s   pi2
  2486.         move.l  #listerr,d0
  2487.         bra     putnam
  2488. pi2        CALL    Forbid,_SysBase(PC)
  2489.         CALL    Remove,_SysBase(PC)
  2490.         move.l  d0,a1
  2491.         move.l  a4,a0
  2492.         move.l  0(a0),d6
  2493.         lea     0(a6,d6),a0
  2494.         CALL    Enqueue,_SysBase(PC)
  2495.         CALL    Permit,_SysBase(PC)
  2496. pi1        rts
  2497. ;set all break signals of a task
  2498. break        move.l  #$f000,d0
  2499.         bra     setthem
  2500.  
  2501. signal        bsr     readhex
  2502.         tst.b   d7
  2503.         beq     syntax
  2504. setthem     move.l  d0,savedat
  2505.         bsr     nodenam
  2506.         moveq.l #2,d7
  2507.         lea     TReNode(PC),a4
  2508.         bsr     findnam
  2509.         tst.b   d7
  2510.         beq.s   pi1
  2511.         move.l  d0,a1
  2512.         move.l  savedat,d0
  2513.         and.l   18(a1),d0
  2514.         CALL    Signal,_SysBase(PC)
  2515.         rts
  2516.  
  2517. ;set up a list of tasknames which should't be displayed
  2518.  
  2519. hide        cmp.b   #10,0(a0)
  2520.         bne.s   hid5
  2521.         bra     syntax
  2522. hid5        lea     hidestart(PC),a2
  2523.         move.l  a2,d3
  2524. hid0        tst.l   0(a2)
  2525.         beq.s   hid1
  2526.         move.l  0(a2),a2
  2527.         lea     4(a2),a1
  2528.         bsr     strcmp
  2529.         tst     d0
  2530.         beq.s   hid2
  2531.         move.l  a2,d3
  2532.         bra.s   hid0
  2533. hid1        move.l  a0,a4
  2534.         bsr     strlen2
  2535.         addq    #5,d0
  2536.         move.l  #65536,d1
  2537.         CALL    AllocMem,_SysBase(PC)
  2538.         tst.l   d0
  2539.         beq.s   hid4
  2540.         move.l  d0,a1
  2541.         move.l  d0,0(a2)
  2542.         addq    #4,a1
  2543. hid3        cmp.b   #10,0(a4)
  2544.         beq.s   hid4
  2545.         move.b  (a4)+,(a1)+
  2546.         bra.s   hid3
  2547. hid4        rts
  2548. hid2        move.l  d3,a3
  2549.         move.l  0(a2),0(a3)
  2550. freehidden  lea     4(a2),a0
  2551.         bsr     strlen
  2552.         addq    #5,d0
  2553.         move.l  a2,a1
  2554.         CALL    FreeMem,_SysBase(PC)
  2555.         rts
  2556.  
  2557. freehidmem  move.l  hidestart(PC),a4
  2558. fhm0        move.l  a4,d0
  2559.         beq.s   fhm1
  2560.         move.l  a4,a2
  2561.         move.l  0(a2),a4
  2562.         bsr     freehidden
  2563.         bra     fhm0
  2564. fhm1        rts
  2565.  
  2566. ;set up an ALIAS list
  2567. alias        cmp.b   #10,0(a0)
  2568.         beq     showalias
  2569.         bsr     strbuf
  2570.         move.l  a0,a5
  2571.         lea     buffer,a0
  2572.         bsr     strlen
  2573.         tst.l   d0
  2574.         beq     syntax
  2575.  
  2576.         moveq   #1,d1
  2577.         cmp     d1,d0
  2578.         bne.s   5$
  2579.         lea     params(PC),a0
  2580.         moveq   #parmnum-1,d1
  2581.         move.b  buffer,d2
  2582. 6$        cmp.b   (a0)+,d2
  2583.         dbeq    d1,6$
  2584.         tst.w   d1
  2585.         bmi.s   5$
  2586.         move.l  #aliaserr,d0
  2587.         bsr     putstr
  2588.         move.l  #params,d0
  2589.         bsr     putstr
  2590.         move.l  #aliaserr2,d0
  2591.         bra     putnam
  2592.  
  2593. 5$        move.l  d0,d5
  2594.         move.l  a5,a0
  2595.         adda.l  d0,a0
  2596.         bsr     kllblnks
  2597.         move.l  a5,-(a7)
  2598.         bsr     findcmd
  2599.         move.l  (a7)+,a5
  2600.         tst.l   d2
  2601.         bmi     syntax
  2602.         move.l  a5,a0
  2603.         bsr     strbuf
  2604.  
  2605.         addq    #6,d5
  2606.         move.l  d5,d0
  2607.         move.l  #65536,d1
  2608.         CALL    AllocMem,_SysBase(PC)
  2609.         tst.l   d0
  2610.         beq.s   1$
  2611.  
  2612.         move.l  aliaslist(PC),d1
  2613.         bne.s   2$
  2614.         move.l  d0,aliaslist
  2615.         bra.s   3$
  2616. 2$        move.l  d1,a0
  2617.         move.l  0(a0),d1
  2618.         bne.s   2$
  2619.         move.l  d0,0(a0)
  2620.  
  2621. 3$        move.l  d0,a0
  2622.         move.b  d2,4(a0)
  2623.  
  2624.         lea     5(a0),a0
  2625.         lea     buffer,a1
  2626. 4$        move.b  (a1)+,(a0)+
  2627.         bne.s   4$
  2628. 1$        rts
  2629.  
  2630. showalias   lea     alhead(PC),a0
  2631.         bsr     puthead
  2632.         move.l  aliaslist(PC),d0
  2633.         beq.s   1$
  2634. 2$        move.l  d0,a5
  2635.         addq    #5,d0
  2636.         bsr     putstr
  2637.         move.w  #15,d1
  2638.         bsr     tab
  2639.         move.l  #equal,d0
  2640.         bsr     putstr
  2641.         move.b  4(a5),d0
  2642.         ext.w   d0
  2643.         bsr     getcmdptr
  2644.         bsr     putnam
  2645.         move.l  0(a5),d0
  2646.         bne.s   2$
  2647. 1$        rts
  2648.  
  2649. freealias   move.l  aliaslist(PC),a4
  2650. 1$        move.l  a4,d0
  2651.         beq.s   2$
  2652.         move.l  a4,a2
  2653.         move.l  0(a2),a4
  2654.         lea     5(a2),a0
  2655.         bsr     strlen
  2656.         addq    #6,d0
  2657.         move.l  a2,a1
  2658.         CALL    FreeMem,_SysBase(PC)
  2659.         bra     1$
  2660. 2$        rts
  2661.  
  2662. getcmdptr   move.l  a0,-(a7)
  2663.         lea     commds(PC),a0
  2664. 2$        tst     d0
  2665.         beq.s   1$
  2666. 3$        tst.b   (a0)+
  2667.         bne.s   3$
  2668.         subq    #1,d0
  2669.         bra.s   2$
  2670. 1$        move.l  a0,d0
  2671.         move.l  (a7)+,a0
  2672.         rts
  2673.  
  2674.  
  2675. ;'flushlibs'
  2676. flush        move.l  #$ffffff,d0
  2677.         moveq   #0,d1
  2678.         CALL    AllocMem,_SysBase(PC)
  2679. flsh1        rts
  2680.  
  2681. ;display library->lib_IDString
  2682. info        bsr     nodenam2
  2683.         moveq.l #2,d7
  2684.         lea     DevNode(PC),a4
  2685.         bsr     findnam
  2686.         tst.b   d7
  2687.         beq.s   flsh1
  2688.         move.l  d0,a0
  2689.         move.l  24(a0),d0
  2690.         beq.s   if1
  2691.         move.l  d0,d1
  2692.         andi.l  #1,d1
  2693.         bne.s   if1
  2694.         bra     putnam
  2695. if1        move.l  #noinfo,d0
  2696.         bsr     putstr
  2697.         move.l  a5,d0
  2698.         bra     putnam
  2699.  
  2700. capture     move.l  _SysBase(PC),a1
  2701.         lea     42(a1),a0
  2702.         moveq   #2,d6
  2703.         lea     coldtxt,a4
  2704. cap0        move.l  a4,d0
  2705.         bsr     putstr
  2706.         move.l  0(a0),d0
  2707.         bne.s   cap1
  2708.         move.l  #unset,d0
  2709.         bsr     putstr
  2710.         bra     cap2
  2711. cap1        bsr     hexa
  2712. cap2        bsr     newline
  2713.         lea     15(a4),a4
  2714.         addq    #4,a0
  2715.         dbf     d6,cap0
  2716.  
  2717.         move.l  #kicktxt,d0
  2718.         bsr     putstr
  2719.         move.l  546(a1),a0
  2720.         cmpa.l  #0,a0
  2721.         bne.s   kickm3
  2722.         move.l  #unset,d0
  2723.         bra     putnam
  2724. kickm3        move.l  a0,-(a7)
  2725.         bsr     newline
  2726.         lea     kickhead(PC),a0
  2727.         bsr     puthead
  2728.         move.l  (a7)+,a0
  2729. kickm0        move.l  a0,d0
  2730.         beq     kickm4
  2731.         bpl.s   kickm1
  2732.         bclr    #31,d0
  2733.         move.l  d0,a0
  2734.         bra.s   kickm0
  2735. kickm1        move.w  14(a0),d6
  2736.         subq    #1,d6
  2737.         lea     16(a0),a2
  2738. kickm2        move.l  0(a2),d0
  2739.         bsr     hexa
  2740.         move.l  0(a2),d0
  2741.         move.l  4(a2),d4
  2742.         add.l   d4,d0
  2743.         bsr     hexa
  2744.         move.l  d4,d0
  2745.         clr.b   d3
  2746.         bsr     longdec
  2747.         bsr     newline
  2748.         addq    #8,a2
  2749.         dbf     d6,kickm2
  2750.         move.l  0(a0),a0
  2751.         bra     kickm0
  2752. kickm4        rts
  2753.  
  2754. clrcold     move.l  _SysBase,a0
  2755.         clr.l   42(a0)
  2756.         bra.s   chksum
  2757. clrcool     move.l  _SysBase,a0
  2758.         clr.l   46(a0)
  2759.         bra.s   chksum
  2760. clrwarm     move.l  _SysBase,a0
  2761.         clr.l   50(a0)
  2762.  
  2763. chksum        lea     34(a0),a1
  2764.         move    #22,d0
  2765. addchk        add     (a1)+,d1
  2766.         dbf     d0,addchk
  2767.         not     d1
  2768.         move.w  d1,82(a0)
  2769.         rts
  2770.  
  2771. ;Save the command line to be repeated. If this line doesn't produce
  2772. ;any output, don't repeat it at all
  2773. repeatcmd   tst.w   repeat
  2774.         bne.s   2$
  2775.         move.w  repeatlen(PC),d0
  2776.         subq    #7,d0
  2777.         move.w  d0,repeatlen
  2778.         lea     repeatbuffer,a1
  2779.         lea     dummy,a2
  2780.         move.w  d0,d1
  2781.         ext.l   d1
  2782. 1$        move.b  0(a0),(a1)+
  2783.         move.b  (a0)+,(a2)+
  2784.         dbf     d1,1$
  2785.  
  2786.         clr.l   lastprinted
  2787.         clr.b   printed
  2788.         move.w  #1,repeat
  2789.         bsr     cli
  2790.         tst.b   printed
  2791.         beq.s   2$
  2792.         bsr     starttimer
  2793.         rts
  2794. 2$        clr.w   repeat
  2795.         rts
  2796.  
  2797. ;save the parameters from a 'window x y width height' call
  2798. setwindow   tst.b   fromfile
  2799.         bne.s   wiw1
  2800. wiw3        move.l  #wiwerr,d0
  2801.         bra     putnam
  2802. wiw1        lea     window_l(PC),a3
  2803.         moveq   #3,d5
  2804. wiw0        bsr     getnum
  2805.         tst     d7
  2806.         beq.s   wiw2
  2807.         move.w  d2,0(a3)
  2808.         addq    #2,a3
  2809.         dbf     d5,wiw0
  2810. wiw2        rts
  2811.  
  2812. ;display ExecBase->LastAlert
  2813. lastalert   movem.l $100,d1-d2
  2814.         tst.l   d1
  2815.         bne.s   al1
  2816.         move.l  _SysBase(PC),a0
  2817.         movem.l 514(a0),d1-d2
  2818. al1        move.l  #gurutxt,d0
  2819.         bsr     putstr
  2820.         move.l  d1,d0
  2821.         bsr     hexa
  2822.         lea     out,a0
  2823.         move.l  ptr(PC),d0
  2824.         move.b  #'.',-1(a0,d0)
  2825.         move.l  d2,d0
  2826.         bsr     hexa
  2827.         bra     newline
  2828.  
  2829. ;toggle CLI-Commands
  2830. clicmd        bchg    #0,cmdcli
  2831.         rts
  2832.  
  2833. ;toggle CPUSE task list
  2834. usage        bchg    #0,usageflag
  2835.         rts
  2836.  
  2837. ;toggle task-header display on/off
  2838. nohead        bchg    #0,headon
  2839.         rts
  2840.  
  2841. ;toggle hide entries on/off
  2842. hidden        bchg    #0,hideon
  2843.         rts
  2844.  
  2845. ;toggle sort on/off
  2846. sort       bchg    #0,sorton
  2847.        rts
  2848.  
  2849. ;toggle task-ports display on/off
  2850. taskports   bchg    #0,tports
  2851. clo1        rts
  2852.  
  2853. ;Open a library
  2854. openlib     bsr     nodenam2
  2855.         move.l  a5,a1
  2856.         moveq   #0,d0
  2857.         CALL    OpenLibrary,_SysBase(PC)
  2858.         tst.l   d0
  2859.         beq     fn5
  2860. opli1        rts
  2861.  
  2862.  
  2863. ;close it
  2864. closelib    bsr     nodenam2
  2865.         moveq   #0,d7
  2866.         lea     LibNode(PC),a4
  2867.         bsr     findnam
  2868.         tst.b   d7
  2869.         beq.s   clo1
  2870.         move.l  d0,a1
  2871.         CALL    CloseLibrary,_SysBase(PC)
  2872.         rts
  2873.  
  2874. remnode     bsr     nodenam2
  2875.         moveq   #7,d7
  2876.         lea     TReNode(PC),a4
  2877.         bsr     findnam
  2878.         tst.b   d7
  2879.         beq.s   1$
  2880.         CALL    Disable,_SysBase(PC)
  2881.         move.l  d0,a1
  2882.         CALL    Remove,_SysBase(PC)
  2883.         CALL    Enable,_SysBase(PC)
  2884. 1$        rts
  2885.  
  2886. ;end Xoper but stay in background
  2887. quithold    lea     in,a0
  2888.         lea     dummy,a1
  2889. qh1        move.b  (a1)+,d0
  2890.         move.b  d0,(a0)+
  2891.         cmp.b   #10,d0
  2892.         bne.s   qh1
  2893.  
  2894. instback    tst.b   background
  2895.         bne.s   cleanit
  2896.         move.b  #1,background
  2897.         bsr     installh
  2898. cleanit     move.l  infile(PC),d1
  2899.         beq.s   ib1
  2900.         CALL    Close,dosbase(PC)
  2901.         clr.l   infile
  2902.         clr.b   fromfile
  2903. ib1        clr.b   running
  2904.         bsr     killpage
  2905.         bsr     freeblank
  2906.         tst.l   wnptr
  2907.         beq.s   5$
  2908.         tst.b   ownscreen
  2909.         bne.s   6$
  2910.         move.l  wnptr(PC),a0
  2911.         move.l  4(a0),window_l
  2912.         move.l  8(a0),window_w
  2913. 6$        move.l  wnptr(PC),a0
  2914.         CALL    CloseWindow,intuibase(PC)
  2915.         clr.l   intuimsg
  2916.         clr.l   wnptr
  2917. 5$        move.l  screenptr(PC),d0
  2918.         beq.s   4$
  2919.         move.l  d0,a0
  2920.         CALL    CloseScreen,intuibase(PC)
  2921.         clr.l   screenptr
  2922.  
  2923.         move.l  realstack(PC),a7
  2924.  
  2925. 4$        tst.b   iconifyon
  2926.         beq.s   1$
  2927.         jsr     iconify
  2928.         bra.s   2$
  2929.  
  2930. 1$        move.l  mysignal(PC),d0
  2931.         or.l    trapsignal(PC),d0
  2932.         CALL    Wait,_SysBase(PC)
  2933. 2$        move.b  #1,running
  2934.         and.l   trapsignal(PC),d0
  2935.         beq.s   3$
  2936.         move.b  #1,gotguru
  2937. 3$        bra     restart
  2938.  
  2939. ;fill all unused memory-chunks with a longword
  2940. clear        moveq   #0,d0
  2941.         cmp.b   #10,0(a0)
  2942.         beq.s   clr5
  2943.         bsr     readhex
  2944.         tst.b   d7
  2945.         beq     syntax
  2946. clr5        move.l  _SysBase(PC),a0
  2947.         clr.l   parmtxt
  2948.         lea     322(a0),a0
  2949.         move.w  #$4000,$dff09a
  2950. clr1        move.l  0(a0),a0
  2951.         tst.l   0(a0)
  2952.         beq.s   clr6
  2953.         move.l  16(a0),a1
  2954. clr2        tst.l   0(a1)
  2955.         beq.s   clr1
  2956.         addq.l  #1,parmtxt
  2957.         move.l  4(a1),d1
  2958.         subq.l  #8,d1
  2959.         ble.s   clr31
  2960.         lsr.l   #2,d1
  2961.         subq.l  #1,d1
  2962.         bmi.s   clr31
  2963.         lea     8(a1),a2
  2964. clr3        move.l  d0,(a2)+
  2965.         dbf     d1,clr3
  2966. clr31        move.l  0(a1),a1
  2967.         bra.s   clr2
  2968. clr6        move.w  #-$4000,$dff09a
  2969.         move.l  parmtxt(PC),d0
  2970.         bsr     longdec
  2971.         move.l  #clrtxt,d0
  2972.         bra     putnam
  2973.  
  2974. ;change the number of maximum lines in the history buffer
  2975. historylines
  2976.         bsr     getnum
  2977.         tst.b   d7
  2978.         beq     syntax
  2979.         move.w  d2,maxhlines
  2980.         move.w  hnum(PC),d0
  2981. 1$        cmp.w   maxhlines(PC),d0
  2982.         ble.s   2$
  2983.         bsr     remhistline
  2984.         subq    #1,d0
  2985.         bra.s   1$
  2986. 2$        move.l  history+8,curhist
  2987.         move.w  d0,hnum
  2988.         rts
  2989. ;set the minimum number of characters a input line
  2990. ;must have to be added to the history buffer
  2991. historylength
  2992.         bsr     getnum
  2993.         tst.b   d7
  2994.         beq     syntax
  2995.         tst.b   d2
  2996.         bne.s   1$
  2997.         addq    #1,d2
  2998. 1$        move.w  d2,minnumchars
  2999.         rts
  3000. ;display all lines in the history buffer
  3001. showhistory move.l  history(PC),a5
  3002.         moveq   #1,d5
  3003. 1$        tst.l   0(a5)
  3004.         beq.s   2$
  3005.         move.l  d5,d3
  3006.         bsr     bytedec
  3007.         move.w  8(a5),d0
  3008.         ext.l   d0
  3009.         lea     10(a5),a0
  3010.         lea     inputbuffer,a1
  3011.         CALL    CopyMem,_SysBase(PC)
  3012.         move.w  8(a5),d0
  3013.         lea     inputbuffer,a1
  3014.         clr.b   0(a1,d0.w)
  3015.         move.l  a1,d0
  3016.         bsr     putnam
  3017.         addq    #1,d5
  3018.         move.l  0(a5),a5
  3019.         bra.s   1$
  3020. 2$        rts
  3021.  
  3022. ;set the maximum lines the output buffer may hold
  3023. outputlines bsr     getnum
  3024.         tst.b   d7
  3025.         beq     syntax
  3026.         moveq   #100,d3
  3027.         tst.l   d2
  3028.         bmi.s   2$
  3029.         cmp.l   d3,d2
  3030.         bge.s   1$
  3031. 2$        move.l  d3,d2
  3032. 1$        move.l  d2,maxlines
  3033.         rts
  3034.  
  3035. ;find a named node
  3036. ;d7 = number of lists to search through
  3037. ;a4 = pointer to the first entry in the
  3038. ;     list-offset-table
  3039. ;a5 = pointer to name
  3040. ;returns:
  3041. ;d7 = TRUE/FALSE 1/0
  3042. ;d0 = node
  3043.  
  3044. findnam     tst.b   0(a5)
  3045.         bne.s   1$
  3046.         move.l  #nameerr,d0
  3047.         bsr     putnam
  3048.         bra     fnerr
  3049. 1$        cmp.b   #'$',0(a5)
  3050.         bne.s   fn2
  3051.         move.l  d7,d2
  3052.         move.l  a5,a0
  3053.         bsr     readhex
  3054.         tst.b   d7
  3055.         beq.s   fn6
  3056.         move.l  d2,d7
  3057.         bsr     tstnode
  3058.         tst.l   d5
  3059.         bne.s   fn3
  3060.         bra     fn5
  3061. fn6        move.l  d2,d7
  3062. fn2        move.l  _SysBase(PC),a0
  3063.         adda.l  0(a4),a0
  3064.         move.l  a5,a1
  3065. fn4        CALL    FindName,_SysBase(PC)
  3066.         tst.l   d0
  3067.         bne.s   fn1
  3068.         addq    #4,a4
  3069.         dbf     d7,fn2
  3070. fn5        move.l  #namerr,d0
  3071.         bsr     putstr
  3072.         move.l  a5,d0
  3073.         bsr     putnam
  3074. fnerr        clr.b   d7
  3075.         rts
  3076. fn1        move.b  procnum(PC),d2
  3077.         beq.s   fn3
  3078.         move.l  d0,a0
  3079.         cmp.b   143(a0),d2
  3080.         bne.s   fn4
  3081. fn3        moveq.l #1,d7
  3082.         rts
  3083.  
  3084. ;list-offset-table
  3085. TRuNode     dc.l    276
  3086. TReNode     dc.l    406
  3087. TWaNode     dc.l    420
  3088. DevNode     dc.l    350
  3089. LibNode     dc.l    378
  3090. ResNode     dc.l    336
  3091. MemNode     dc.l    322
  3092. PorNode     dc.l    392
  3093. SemNode     dc.l    532
  3094.  
  3095. ;Node has been entered in hex. Check if this node exsists
  3096. tstnode     tst.b   fromfile
  3097.         bne.s   illegalhex
  3098.         move.l  d0,d1
  3099.         btst    #0,d1
  3100.         beq.s   inrange
  3101.         move.l  #adrerr,d0
  3102.         bsr     putnam
  3103. illegalhex  moveq   #0,d5
  3104.         rts
  3105. inrange     movem.l d7/a4,-(a7)
  3106.         cmp.l   #TRuNode,a4
  3107.         bne.s   inrange1
  3108.         move.l  _SysBase(PC),a0
  3109.         cmp.l   276(a0),d0
  3110.         beq.s   nodefound
  3111.         subq    #1,d7
  3112.         addq    #4,a4
  3113. inrange1    move.w  #$4000,$dff09a
  3114. getlist     move.l  _SysBase(PC),a0
  3115.         add.l   0(a4),a0
  3116. nxtnode     tst.l   0(a0)
  3117.         beq.s   nxtlist
  3118.         cmp.l   a0,d0
  3119.         beq.s   nodefound
  3120.         move.l  0(a0),a0
  3121.         bra.s   nxtnode
  3122. nxtlist     addq    #4,a4
  3123.         dbf     d7,getlist
  3124.         move.w  #-$4000,$dff09a
  3125.         movem.l d0/d7/a4,-(a7)
  3126.         bsr     ResumeOutput
  3127.         move.l  #noderr,d0
  3128.         bsr     putnam
  3129.         bsr     readline
  3130.         movem.l (a7)+,d0/d7/a4
  3131.         cmp.b   #'y',inputbuffer
  3132.         beq.s   nodefound1
  3133.         moveq   #0,d5
  3134.         movem.l (a7)+,d7/a4
  3135.         rts
  3136. nodefound   move.w  #-$4000,$dff09a
  3137. nodefound1  move.b  #1,d5
  3138. etst        movem.l (a7)+,d7/a0
  3139.         rts
  3140.  
  3141. ;allocate FileInfoBlock
  3142. allocfinfo  move.l  #260,d0
  3143.         moveq   #0,d1
  3144.         CALL    AllocMem,_SysBase(PC)
  3145.         move.l  d0,finfoptr
  3146.         rts
  3147.  
  3148. ;free FileInfoBlock
  3149. freefinfo   move.l  #260,d0
  3150.         move.l  finfoptr(PC),d1
  3151.         beq.s   1$
  3152.         move.l  d1,a1
  3153.         CALL    FreeMem,_SysBase(PC)
  3154. 1$        rts
  3155.  
  3156. ;Examine ,d0=Lock
  3157. getfinfo    move.l  d0,d1
  3158.         move.l  finfoptr,d2
  3159.         CALL    Examine,dosbase(PC)
  3160.         rts
  3161.  
  3162. ;construct a Pathname from a lock
  3163. ;d0=Lock ,resulting string is written to window
  3164. getpath     movem.l d1-d7/a0-a6,-(a7)
  3165.         move.l  d0,d1
  3166.         beq.s   1$
  3167.         CALL    DupLock,dosbase(PC)
  3168. 1$        lea     out,a4
  3169.         clr.b   -(a4)
  3170. gp0        move.l  d0,-(a7)
  3171.         bsr     getfinfo
  3172.         move.l  finfoptr,a0
  3173.         move.l  4(a0),d4
  3174.         addq    #8,a0
  3175.         bsr     strlen
  3176.         lea     -1(a4),a5
  3177.         tst.l   d4
  3178.         bmi.s   nodir
  3179.         move.b  #'/',-(a4)
  3180. nodir        subq    #1,d0
  3181.         bmi.s   nofnam
  3182. gp1        move.b  0(a0,d0),-(a4)
  3183.         dbf     d0,gp1
  3184. nofnam        move.l  0(a7),d1
  3185.         CALL    ParentDir,dosbase(PC)
  3186.         move.l  d0,d4
  3187.         move.l  (a7)+,d1
  3188.         beq.s   2$
  3189.         CALL    UnLock,dosbase(PC)
  3190. 2$        move.l  d4,d0
  3191.         bne     gp0
  3192. putall        cmp.b   #'/',0(a5)
  3193.         bne.s   gp2
  3194.         move.b  #':',0(a5)
  3195. gp2        move.l  a4,d0
  3196.         bsr     putnam
  3197.         movem.l (a7)+,d1-d7/a0-a6
  3198.         rts
  3199. strlen        move.l  a0,-(a7)
  3200.         moveq   #-1,d0
  3201. strl2        addq.l  #1,d0
  3202.         tst.b   (a0)+
  3203.         bne.s   strl2
  3204.         move.l  (a7)+,a0
  3205.         rts
  3206. strlen2     move.l  a0,-(a7)
  3207.         move.l  #-1,d0
  3208. strl22        addq.l  #1,d0
  3209.         cmp.b   #10,(a0)+
  3210.         bne.s   strl22
  3211.         move.l  (a7)+,a0
  3212.         rts
  3213.  
  3214. ;write a title and underline
  3215. ;a0 = pointer to text
  3216. puthead1    bsr     strlen
  3217.         move.l  d0,d5
  3218.         move.l  a0,d0
  3219.         bra     putstr
  3220.  
  3221. puthead2    bsr     strlen
  3222.         add.l   d0,d5
  3223.         bra.s   ph2
  3224.  
  3225. puthead     bsr     strlen
  3226.         move.l  d0,d5
  3227. ph2        move.l  a0,d0
  3228.         bsr     putnam
  3229.         lea     out,a0
  3230.         move.l  a0,d0
  3231. ph1        move.b  #'-',(a0)+
  3232.         dbf     d5,ph1
  3233.         move.b  #$0a,(a0)+
  3234.         clr.b   0(a0)
  3235.         bra     putstr
  3236.  
  3237. ;move cursor to a column
  3238. ;d0 = current position
  3239. ;d1 = column
  3240. tab        move.l  a3,-(a7)
  3241.         lea     out,a3
  3242. sp5        cmp.b   d1,d0
  3243.         bcc.s   sp4
  3244.         move.b  #' ',0(a3,d0)
  3245.         addq.b  #1,d0
  3246.         bra.s   sp5
  3247. sp4        move.l  d1,ptr
  3248.         move.l  (a7)+,a3
  3249.         rts
  3250.  
  3251. ;convert ascii to byte
  3252. ;a0 = pointer to text
  3253. ;d0 = byte
  3254. getnum        cmp.b   #'$',0(a0)
  3255.         bne.s   isdec
  3256.         bsr     readhex
  3257.         move.l  d0,d2
  3258.         rts
  3259. isdec        moveq   #0,d2
  3260.         move.l  d2,d3
  3261.         move.l  d2,d6
  3262.         move.l  d2,d7
  3263.         cmp.b   #'-',0(a0)
  3264.         bne.s   gn1
  3265.         addq    #1,a0
  3266.         moveq.l #1,d6
  3267. gn1        move.b  (a0)+,d3
  3268.         cmp.b   #'9',d3
  3269.         bhi.s   gn2
  3270.         cmp.b   #'0',d3
  3271.         bcs.s   gn2
  3272.         moveq   #1,d7
  3273.         and.b   #$f,d3
  3274.         muls    #10,d2
  3275.         add.l   d3,d2
  3276.         bra.s   gn1
  3277. gn2        tst.b   d6
  3278.         beq.s   gn3
  3279.         neg.l   d2
  3280. gn3        tst.b   d7
  3281.         bne.s   gn4
  3282.         subq    #1,a0
  3283. gn4        rts
  3284.  
  3285. getfrac     bsr     isdec
  3286.         muls    #10,d2
  3287.         cmp.b   #'.',-1(a0)
  3288.         bne.s   1$
  3289.         moveq   #0,d0
  3290.         move.b  (a0)+,d1
  3291.         cmp.b   #10,d1
  3292.         beq.s   1$
  3293.         and.b   #15,d1
  3294.         add.l   d1,d2
  3295. 1$        rts
  3296.  
  3297. ;convert hex to longword
  3298. ;a0 = pointer to text
  3299. ;returns d0=value
  3300. ;d7 = ok/error 1/0
  3301. readhex     movem.l d1-d6/a1-a5,-(a7)
  3302.         moveq   #1,d7
  3303.         cmp.b   #'$',0(a0)
  3304.         bne.s   rh3
  3305.         addq    #1,a0
  3306. rh3        moveq   #0,d0
  3307.         cmpi.b  #10,0(a0)
  3308.         beq.s   rherr
  3309.         lea     hextab(pc),a1
  3310. rh0        move.b  (a0)+,d3
  3311.         moveq.l #15,d2
  3312. rh1        cmp.b   0(a1,d2),d3
  3313.         beq.s   rh2
  3314.         dbf     d2,rh1
  3315.         bra     rhend
  3316. rh2        lsl.l   #4,d0
  3317.         or.b    d2,d0
  3318.         bra.s   rh0
  3319. rhend        tst.b   d3
  3320.         beq.s   rhok
  3321.         cmpi.b  #10,d3
  3322.         beq.s   rhok
  3323.         cmpi.b  #' ',d3
  3324.         beq.s   rhok
  3325. rherr        moveq   #0,d7
  3326. rhok        movem.l (a7)+,d1-d6/a1-a5
  3327.         rts
  3328.  
  3329. ;skip blanks
  3330. ;a0 pointer to text
  3331. ; returns a0 = new pointer position
  3332. kllblnks    cmpi.b  #' ',0(a0)
  3333.         bne.s   gn4
  3334.         addq    #1,a0
  3335.         bra.s   kllblnks
  3336.  
  3337. ; exit program. If background flag is set, wait for
  3338. ; amiga-amiga-x
  3339.  
  3340. stopall     addq    #4,a7
  3341.         bra     exitall
  3342.  
  3343. exit        tst.b   background
  3344.         bne     quithold
  3345. exitall     bsr     killpage
  3346.         bsr     freeblank
  3347.         bsr     killhistory
  3348.         move.l  stplist(PC),a3
  3349.         tst.l   0(a3)
  3350.         beq.s   ex0
  3351.         move.l  a3,d0
  3352.         bsr     waok
  3353.         bra.s   exitall
  3354.  
  3355. ex0        tst.b   background
  3356.         beq.s   ex1
  3357.         bsr     removeh
  3358.  
  3359. ex1        move.l  _SysBase(PC),a1
  3360.         move.l  #_LVOSwitch,a0
  3361.         move.l  oldswitch,d0
  3362.         CALL    SetFunction,_SysBase(PC)
  3363.         moveq   #3,d0
  3364.         lea     IOCounter(PC),a1
  3365.         CALL    RemIntServer,_SysBase(PC)
  3366.  
  3367.         move.l  replyport(PC),-(a7)
  3368.         LIBCALL DeletePort
  3369.         addq    #4,a7
  3370.         bsr     stoptimer
  3371.         lea     timerio,a1
  3372.         CALL    CloseDevice,_SysBase(PC)
  3373.         move.l  timerport(PC),-(a7)
  3374.         LIBCALL DeletePort
  3375.         addq    #4,a7
  3376.  
  3377.         bsr     restoretrap
  3378.  
  3379.         tst.l   wnptr
  3380.         beq.s   5$
  3381.         move.l  wnptr(PC),a0
  3382.         CALL    CloseWindow,intuibase(PC)
  3383. 5$        move.l  screenptr(PC),d0
  3384.         beq.s   6$
  3385.         move.l  d0,a0
  3386.         CALL    CloseScreen,intuibase(PC)
  3387.         clr.l   screenptr
  3388.  
  3389. 6$        move.l  infile(PC),d1
  3390.         beq.s   ex11
  3391.         CALL    Close,dosbase(PC)
  3392. ex11        bsr     freehidmem
  3393.         bsr     freealias
  3394.         bsr     clrfkeys
  3395.         move.l  realstack(PC),a7
  3396.     IFND DEBUG
  3397.         CALL    Forbid,_SysBase(PC)
  3398.         move.l  wbmsg(PC),d0
  3399.         beq.s   todos
  3400.         move.l  d0,a1
  3401.         CALL    ReplyMsg,_SysBase(PC)
  3402.         moveq   #0,d0
  3403.         rts
  3404.  
  3405. todos        move.l  mytask(PC),a0
  3406.         move.l  152(a0),d1
  3407.         CALL    UnLock,dosbase(PC)
  3408.         move.l  myseg(PC),d1
  3409.         CALL    UnLoadSeg,dosbase(PC)
  3410.     ENDC
  3411.         moveq   #0,d0
  3412.         rts
  3413.  
  3414. ;print a bcpl-string
  3415. ;d0 = bcpl-pointer to bcpl-string
  3416. putbcpl     movem.l d3/a0-a1,-(a7)
  3417.         tst.l   d0
  3418.         beq.s   pb1
  3419.         lsl.l   #2,d0
  3420.         move.l  d0,a1
  3421.         moveq   #0,d3
  3422.         move.b  (a1)+,d3
  3423.         subq    #1,d3
  3424.         move.l  ptr(PC),d0
  3425.         lea     out,a0
  3426. pb2        move.b  (a1)+,0(a0,d0)
  3427.         beq.s   1$
  3428.         addq.b  #1,d0
  3429.         dbf     d3,pb2
  3430. 1$        move.l  d0,ptr
  3431. pb1        movem.l (a7)+,d3/a0-a1
  3432.         rts
  3433.  
  3434. ;compare strings
  3435. ;a0/a1 = pointers to string
  3436. ;returns d0 = true(0) false(1), d1 = length
  3437. strcmp        movem.l a0-a1,-(a7)
  3438.         moveq   #0,d0
  3439.         move.l  d0,d1
  3440. src2        move.b  (a0)+,d0
  3441.         beq.s   src1
  3442.         cmp.b   #10,d0
  3443.         beq.s   src1
  3444.         addq    #1,d1
  3445.         cmp.b   (a1)+,d0
  3446.         beq.s   src2
  3447.         bra.s   src3
  3448. src1        move.b  0(a1),d0
  3449. src3        movem.l (a7)+,a0-a1
  3450.         rts
  3451.  
  3452. strbuf        movem.l d0/a1-a2,-(a7)
  3453.         move.l  a0,a1
  3454.         lea     buffer,a2
  3455. 1$        move.b  (a1)+,d0
  3456.         cmp.b   #10,d0
  3457.         beq.s   2$
  3458.         cmp.b   #' ',d0
  3459.         beq.s   2$
  3460.         or.b    #' ',d0
  3461.         beq.s   2$
  3462.         move.b  d0,(a2)+
  3463.         bra.s   1$
  3464. 2$        clr.b   (a2)+
  3465.         movem.l (a7)+,d0/a1-a2
  3466.         rts
  3467.  
  3468. ;compare bcpl string with string
  3469. ;a0 = pointer to string
  3470. ;a2 = bcpl-pointer to bcpl-string
  3471. ;returns d0 = true(0) false(1)
  3472. strbcmp     movem.l d1/a0/a2,-(a7)
  3473.         moveq   #0,d0
  3474.         moveq   #0,d1
  3475.         adda.l  a2,a2
  3476.         adda.l  a2,a2
  3477.         move.b  (a2)+,d1
  3478.         beq.s   stb1
  3479.         subq    #1,d1
  3480. stb2        cmp.b   (a2)+,(a0)+
  3481.         bne.s   stb1
  3482.         dbf     d1,stb2
  3483.         moveq   #1,d0
  3484. stb1        movem.l (a7)+,d1/a0/a2
  3485.         rts
  3486.  
  3487. ;add a fkey definition to the fkey list. Each entry
  3488. ;looks like this: long Succ, long Pred, byte Key#, byte length,
  3489. ;          char text[]
  3490.  
  3491. setfkey     bsr     nodenam
  3492.         move.b  procnum(PC),d5
  3493.         beq     syntax
  3494.         cmp.b   #21,d5
  3495.         bge     syntax
  3496.         subq    #1,d5
  3497.         move.b  d5,procnum
  3498.         lea     fkeys(PC),a1
  3499. 1$        move.l  0(a1),a1
  3500.         tst.l   0(a1)
  3501.         beq.s   2$
  3502.         cmp.b   8(a1),d5
  3503.         bne.s   1$
  3504.         move.l  a1,d3
  3505.         CALL    Remove,_SysBase(PC)
  3506.         move.l  d3,a1
  3507.         bsr     removefkey
  3508. 2$        tst.b   0(a5)
  3509.         beq.s   4$
  3510.         move.l  a5,a0
  3511.         bsr     strlen
  3512.         move.l  d0,d5
  3513.         add.w   #10,d0
  3514.         moveq   #0,d1
  3515.         CALL    AllocMem,_SysBase(PC)
  3516.         tst.l   d0
  3517.         beq.s   4$
  3518.         move.l  d0,a1
  3519.         move.l  d0,a4
  3520.         move.b  procnum(PC),8(a1)
  3521.         move.b  d5,9(a1)
  3522.         lea     fkeys(PC),a0
  3523.         CALL    AddHead,_SysBase(PC)
  3524.         lea     10(a4),a4
  3525.         subq    #1,d5
  3526. 3$        move.b  (a5)+,(a4)+
  3527.         dbeq    d5,3$
  3528. 4$        rts
  3529.  
  3530. clrfkeys    lea     fkeys(PC),a0
  3531.         CALL    RemHead,_SysBase(PC)
  3532.         tst.l   d0
  3533.         beq.s   1$
  3534.         move.l  d0,a1
  3535.         bsr     removefkey
  3536.         bra.s   clrfkeys
  3537. 1$        rts
  3538.  
  3539. removefkey  move.b  0(a1),d0
  3540.         ext.w   d0
  3541.         ext.l   d0
  3542.         add.w   #10,d0
  3543.         CALL    FreeMem,_SysBase(PC)
  3544.         rts
  3545.  
  3546. ;convert long to decimal
  3547. ;d0 = value
  3548. ;d3 bit 0 = left/right justified
  3549. ;d3 bit 1 = write/leave
  3550. ;returns string in 'buffer'
  3551. longdec     movem.l d1-d2/a1-a2,-(a7)
  3552.         tst.l   d0
  3553.         bmi.s   2$
  3554.         cmp.l   #9999999,d0
  3555.         ble.s   1$
  3556. 2$        move.l  #smallnix,d0
  3557.         bra.s   ld6
  3558. 1$        lea     binarea+8(PC),a1
  3559.         move.l  #'    ',-8(a1)
  3560.         move.l  #'    ',-4(a1)
  3561.         clr.b   0(a1)
  3562.         subq    #1,a1
  3563.         cmp     #2,d3
  3564.         bne.s   ld5
  3565.         clr.b   0(a1)
  3566. ld5        moveq   #1,d2
  3567. ld2        addq    #1,d2
  3568.         moveq   #$a,d1
  3569.         bsr     div
  3570.         addi.l  #$30,d1
  3571.         move.b  d1,-(a1)
  3572.         tst.l   d0
  3573.         bne.s   ld2
  3574.  
  3575.         btst    #0,d3
  3576.         bne.s   ld1
  3577.         lea     binarea(PC),a2
  3578.         cmpa.l  a2,a1
  3579.         bne.s   ld3
  3580.         subq.l  #1,ptr
  3581.         bra.s   ld1
  3582. ld3        move.b  0(a1),(a2)+
  3583.         move.b  #' ',(a1)+
  3584.         dbf     d2,ld3
  3585. ld1        cmp     #2,d3
  3586.         beq.s   ld4
  3587.         move.l  #binarea,d0
  3588. ld6        bsr     putstr
  3589. ld4        movem.l (a7)+,d1-d2/a1-a2
  3590.         rts
  3591.  
  3592. ;write UBYTE
  3593. ;d3 = value
  3594. bytedec     bsr     dec
  3595.         move.l  #decimal,d0
  3596.         bra.s   pm1
  3597.  
  3598. ;write signed byte
  3599. ;d3 = value
  3600. plusmins    movem.l d5/a3,-(a7)
  3601.         move.w  #$2020,minus
  3602.         move.b  d3,d5
  3603.         bpl.s   2$
  3604.         neg.b   d3
  3605. 2$        bsr.s   dec
  3606.         tst.b   d5
  3607.         bpl.s   1$
  3608.         move.l  d0,a3
  3609.         move.b  #'-',-(a3)
  3610. 1$        movem.l (a7)+,d5/a3
  3611.         move.l  #minus+1,d0
  3612. pm1        bra     putstr
  3613.  
  3614. dec        movem.l d3/a3,-(a7)
  3615.         move.l  #$20202020,decimal
  3616.         and.l   #$ff,d3
  3617.         lea     decimal+3(PC),a3
  3618. bloop        tst.b   d3
  3619.         beq.s   bend
  3620.         divu    #10,d3
  3621.         swap    d3
  3622.         ori.b   #'0',d3
  3623.         move.b  d3,-(a3)
  3624.         clr.w   d3
  3625.         swap    d3
  3626.         bra.s   bloop
  3627. bend        cmpa.l  #decimal+3,a3
  3628.         bne     1$
  3629.         move.b  #'0',-(a3)
  3630. 1$        move.l  a3,d0
  3631.         movem.l (a7)+,d3/a3
  3632.         rts
  3633.  
  3634. ;write a string, move cursor into next line
  3635. ;d0 = pointer to text
  3636. putnam        bsr     putstr
  3637. putnam1     tst.b   d0
  3638.         beq.s   ncr
  3639.         bsr     newline
  3640. ncr        rts
  3641.  
  3642. ;write one char
  3643. ;d0 = char
  3644. putchar     movem.l d1/a0,-(a7)
  3645.         move.l  ptr(PC),d1
  3646.         lea     out,a0
  3647.         move.b  d0,0(a0,d1)
  3648.         addq.l  #1,ptr
  3649.         movem.l (a7)+,d1/a0
  3650.         rts
  3651.  
  3652. ;write a string, strings are only put into the output buffer when
  3653. ;a LF is detected
  3654. ;d0 = pointer to string
  3655. ;returns d0 = cursor position
  3656. putstr        movem.l d1-d7/a0-a6,-(a7)
  3657.         move.b  #1,printed
  3658.         move.l  d0,a2
  3659.         lea     out,a3
  3660.         move.l  ptr(PC),d0
  3661.         move.l  a2,d5
  3662.         bne     pst1
  3663.         lea     longnix(PC),a2
  3664.  
  3665. pst1        move.b  (a2)+,d1
  3666.         cmpi.b  #13,d1
  3667.         beq     pst1
  3668.         cmpi.b  #10,d1
  3669.         beq.s   lineend
  3670.         move.b  d1,0(a3,d0)
  3671.         beq     prend
  3672.         cmp     #100,d0
  3673.         bge.s   pst1
  3674.         addq    #1,d0
  3675.         bra.s   pst1
  3676.  
  3677. lineend     tst.b   fromfile
  3678.         beq.s   1$
  3679.         moveq   #0,d0
  3680.         bra     prend
  3681.  
  3682. 1$        tst.l   lastprinted
  3683.         bne.s   2$
  3684.         bsr     killpage
  3685.  
  3686. 2$        addq    #1,d0
  3687.         move.l  d0,-(a7)
  3688.         add     #14,d0
  3689.         moveq   #0,d1
  3690.         CALL    AllocMem,_SysBase(PC)
  3691.         move.l  (a7)+,d1
  3692.         tst.l   d0
  3693.         beq     prend
  3694.         move.l  d0,a0
  3695.         move.w  d1,12(a0)
  3696.         cmp.w   maxllength(PC),d1
  3697.         ble.s   7$
  3698.         move.w  d1,maxllength
  3699. 7$        move.l  node,8(a0)
  3700.         clr.l   node
  3701.         clr.l   0(a0)
  3702.  
  3703.         move.l  lastprinted(PC),d0
  3704.         move.l  d0,4(a0)
  3705.         bne.s   3$
  3706.         move.l  a0,outchain
  3707.         bra.s   4$
  3708. 3$        move.l  d0,a1
  3709.         move.l  a0,0(a1)
  3710. 4$        move.l  a0,lastprinted
  3711.         move.b  #' ',14(a0)
  3712.         subq    #1,d1
  3713.         lea     15(a0),a0
  3714.         lea     out,a1
  3715.         subq    #1,d1
  3716.         bmi.s   6$
  3717. 5$        move.b  (a1)+,(a0)+
  3718.         dbf     d1,5$
  3719. 6$        move.l  numlines(PC),d2
  3720.         cmp.l   maxlines(PC),d2
  3721.         ble.s   8$
  3722.  
  3723.         move.l  outchain(PC),a1
  3724.         move.l  0(a1),a2
  3725.         move.l  a2,outchain
  3726.         clr.l   4(a2)
  3727.         move.w  12(a1),d0
  3728.         add.w   #14,d0
  3729.         ext.l   d0
  3730.         CALL    FreeMem,_SysBase(PC)
  3731.         bra.s   9$
  3732.  
  3733. 8$        addq.l  #1,d2
  3734.         move.l  d2,numlines
  3735.  
  3736. 9$        moveq   #0,d0
  3737.         move.l  d0,d5
  3738.         tst.b   addlines
  3739.         beq     pst1
  3740.         bsr     addline
  3741.         bra     pst1
  3742. prend        move.l  d0,ptr
  3743.         movem.l (a7)+,d1-d7/a0-a6
  3744.         rts
  3745.  
  3746. ;Kill output buffer
  3747. killpage    movem.l d0-d7/a0-a6,-(a7)
  3748.         tst.l   outchain
  3749.         beq.s   2$
  3750.         move.l  outchain(PC),a1
  3751.         bsr     killlines
  3752.         clr.l   outchain
  3753.         clr.l   lastprinted
  3754.         clr.l   numlines
  3755.         clr.w   maxllength
  3756. 2$        movem.l (a7)+,d0-d7/a0-a6
  3757.         rts
  3758.  
  3759. ;kill the remainder of the output buffer
  3760. killlines   move.l  0(a1),-(a7)
  3761.         move.w  12(a1),d0
  3762.         ext.l   d0
  3763.         add     #14,d0
  3764.         CALL    FreeMem,_SysBase(PC)
  3765.         move.l  (a7)+,a1
  3766.         move.l  a1,d7
  3767.         bne.s   killlines
  3768.         rts
  3769.  
  3770. freeblank   move.l  blanks(PC),d0
  3771.         beq.s   1$
  3772.         move.l  d0,a1
  3773.         move.w  colms(PC),d0
  3774.         ext.l   d0
  3775.         CALL    FreeMem,_SysBase(PC)
  3776.         clr.l   blanks
  3777. 1$        rts
  3778.  
  3779. ;write a portion of the output buffer to the screen
  3780. blastout    move.l  rastport(PC),a1
  3781.         moveq   #1,d0
  3782.         CALL    SetAPen,gfxbase(PC)
  3783.         move.l  rastport(PC),a1
  3784.         moveq   #1,d0
  3785.         CALL    SetDrMd,gfxbase(PC)
  3786.         moveq   #0,d7
  3787.  
  3788.         move.w  loffset(PC),d2
  3789.         beq.s   7$
  3790.         move.w  colms(PC),d4
  3791.         add.w   d4,d2
  3792.         move.w  maxllength(PC),d3
  3793.         cmp.w   d3,d2
  3794.         ble.s   7$
  3795.         move.w  d3,d2
  3796.         sub.w   d4,d2
  3797.         bpl.s   8$
  3798.         moveq   #0,d2
  3799. 8$        move.w  d2,loffset
  3800.  
  3801. 7$        bsr     tstfirstlin
  3802.  
  3803. 1$        tst.l   outchain
  3804.         beq.s   3$
  3805.         bsr     findline
  3806.  
  3807. 2$        move.w  colms(PC),d5
  3808.         ext.l   d5
  3809.         move.w  loffset(PC),d4
  3810.         ext.l   d4
  3811.         moveq   #18,d6
  3812. 6$        lea     14(a5,d4),a0
  3813.         move.w  12(a5),d3
  3814.         ext.l   d3
  3815.         bsr     blastline
  3816.         bge.s   3$
  3817.         tst.l   0(a5)
  3818.         beq.s   5$
  3819.         move.l  0(a5),a5
  3820.         bra     6$
  3821. 5$        moveq   #0,d3
  3822.         bsr     blastline
  3823.         bcs.s   5$
  3824. 3$        rts
  3825.  
  3826. ;get a pointer to a line  (line # in d0)
  3827. findline    move.l  outchain(PC),d1
  3828.         beq     2$
  3829.         move.l  d1,a5
  3830. 1$        tst     d0
  3831.         beq.s   2$
  3832.         tst.l   0(a5)
  3833.         beq.s   2$
  3834.         move.l  0(a5),a5
  3835.         dbf     d0,1$
  3836. 2$        rts
  3837.  
  3838. ;check if the display is as 'full' as possible
  3839. tstfirstlin move.l  firstline(PC),d0
  3840.         move.l  d0,d2
  3841.         add.w   rows(PC),d2
  3842.         cmp.l   numlines(PC),d2
  3843.         bmi.s   1$
  3844.         move.l  numlines(PC),d2
  3845.         sub.w   rows(PC),d2
  3846.         bpl.s   4$
  3847.         moveq   #0,d2
  3848. 4$        move.l  d2,d0
  3849.         move.l  d2,firstline
  3850. 1$        rts
  3851.  
  3852. ;display one line, fill the gap between the end of the line and
  3853. ;the end of the window with spaces.
  3854. ;d6 = ypos, d5=colms, d3= linelength, d7= line # in window, a0 = text
  3855.  
  3856. blastline   move    d6,d1
  3857.         moveq   #6,d0
  3858.         move.l  rastport(PC),a1
  3859.         CALL    Move,gfxbase(PC)
  3860.         sub.w   d4,d3
  3861.         bpl.s   7$
  3862.         moveq   #0,d3
  3863.         bra.s   6$
  3864. 7$        cmp.w   d5,d3
  3865.         bmi.s   4$
  3866.         move.w  d5,d3
  3867. 4$        move.l  d3,d0
  3868.         beq.s   6$
  3869.         move.l  rastport(PC),a1
  3870.         CALL    Text,gfxbase(PC)
  3871. 6$        move.l  d5,d0
  3872.         sub.l   d3,d0
  3873.         ble.s   5$
  3874.         move.l  blanks(PC),a0
  3875.         move.l  rastport(PC),a1
  3876.         CALL    Text,gfxbase(PC)
  3877. 5$        addq    #8,d6
  3878.         addq    #1,d7
  3879.         cmp.w   rows(PC),d7
  3880.         rts
  3881.  
  3882. ;Write pointer, display '-------' if empty
  3883. hexan        tst.l   d0
  3884.         bne.s   hexa
  3885.         bra     putstr
  3886.  
  3887. ;Write 8 byte hex value
  3888. ;d0 = value
  3889. hexa        bsr     gthex
  3890.         bra     putstr
  3891.  
  3892. gthex        movem.l d1-d7/a0-a6,-(a7)
  3893.         moveq.l #7,d5
  3894.         lea     hexarea(PC),a1
  3895.         lea     hextab(PC),a0
  3896.         moveq   #0,d2
  3897. hexloop     move.b  d0,d2
  3898.         and.b   #15,d2
  3899.         move.b  0(a0,d2),0(a1,d5)
  3900.         lsr.l   #4,d0
  3901.         dbf     d5,hexloop
  3902.         move.l  a1,d0
  3903.         movem.l (a7)+,d1-d7/a0-a6
  3904.         rts
  3905.  
  3906. ;Convert/write byte into binary string
  3907. ;d0 = value
  3908. bin        movem.l d1-d7/a0-a6,-(a7)
  3909.         lea     binarea(PC),a0
  3910.         move.w  #$2020,8(a0)
  3911.         moveq.l #7,d4
  3912. binloop     moveq.l #'0'/2,d1
  3913.         roxr.b  #1,d0
  3914.         roxl.b  #1,d1
  3915.         move.b  d1,0(a0,d4)
  3916.         dbf     d4,binloop
  3917.         move.l  a0,d0
  3918.         movem.l (a7)+,d1-d7/a0-a6
  3919.         bra     putstr
  3920.  
  3921. ;send a packet
  3922. ;a0 = msgport
  3923. ;dp_Type and dp_Arg1 have to be inizialized
  3924. cons1        movem.l d0-d7/a0-a6,-(a7)
  3925.         move.l  #dp_Link,LN_NAME
  3926.         move.l  #mypacket,dp_Link
  3927.         move.l  replyport(PC),dp_Port
  3928.         lea     mypacket,a1
  3929.         CALL    PutMsg,_SysBase(PC)
  3930.         move.l  replyport,a0
  3931.         CALL    WaitPort,_SysBase(PC)
  3932.         move.l  replyport(PC),a0
  3933.         CALL    GetMsg,_SysBase(PC)
  3934.         movem.l (a7)+,d0-d7/a0-a6
  3935.         rts
  3936.  
  3937. ;32-bit division
  3938. ;d0 / d1
  3939. ;returns d0
  3940. div        movem.l d2-d3,-(a7)
  3941.         tst.l   d1
  3942.         beq     div8
  3943.         swap    d1
  3944.         move.w  d1,d2
  3945.         bne.s   div1
  3946.         swap    d0
  3947.         swap    d1
  3948.         swap    d2
  3949.         move.w  d0,d2
  3950.         beq.s   div2
  3951.         divu    d1,d2
  3952.         move.w  d2,d0
  3953. div2        swap    d0
  3954.         move.w  d0,d2
  3955.         divu    d1,d2
  3956.         move.w  d2,d0
  3957.         swap    d2
  3958.         move.w  d2,d1
  3959.         bra     div8
  3960. div1        moveq   #$10,d3
  3961.         cmpi.w  #$80,d1
  3962.         bcc.s   div3
  3963.         rol.l   #8,d1
  3964.         subq.w  #8,d3
  3965. div3        cmpi.w  #$800,d1
  3966.         bcc.s   div4
  3967.         rol.l   #4,d1
  3968.         subq.w  #4,d3
  3969. div4        cmpi.w  #$2000,d1
  3970.         bcc.s   div5
  3971.         rol.l   #2,d1
  3972.         subq.w  #2,d3
  3973. div5        tst.w   d1
  3974.         bmi.s   div6
  3975.         rol.l   #1,d1
  3976.         subq.w  #1,d3
  3977. div6        move.w  d0,d2
  3978.         lsr.l   d3,d0
  3979.         swap    d2
  3980.         clr.w   d2
  3981.         lsr.l   d3,d2
  3982.         swap    d3
  3983.         divu    d1,d0
  3984.         move.w  d0,d3
  3985.         move.w  d2,d0
  3986.         move.w  d3,d2
  3987.         swap    d1
  3988.         mulu    d1,d2
  3989.         sub.l   d2,d0
  3990.         bcc.s   div7
  3991.         subq.w  #1,d3
  3992.         add.l   d1,d0
  3993. div7        moveq   #0,d1
  3994.         move.w  d3,d1
  3995.         swap    d3
  3996.         rol.l   d3,d0
  3997.         swap    d0
  3998.         exg     d1,d0
  3999. div8        movem.l (a7)+,d2-d3
  4000.         rts
  4001.  
  4002. ;install a input-handler
  4003. installh    pea     0
  4004.         pea     xopsleep
  4005.         LIBCALL CreatePort
  4006.         addq    #8,a7
  4007.         move.l  d0,InputMsg
  4008.         move.l  d0,-(a7)
  4009.         LIBCALL CreateStdIO
  4010.         addq    #4,a7
  4011.         move.l  d0,InRequest
  4012.         move.l  d0,a1
  4013.         lea     devicenam(PC),a0
  4014.         moveq   #0,d0
  4015.         moveq   #0,d1
  4016.         CALL    OpenDevice,_SysBase(PC)
  4017.         move.l  d0,devstatus
  4018.         movea.l InRequest(PC),a1
  4019.         move.l  #InInterrupt,40(a1)
  4020.         move.w  #9,28(a1)
  4021.         CALL    DoIO,_SysBase(PC)
  4022.         move.l  d0,iostatus
  4023.         move.l  #-1,d0
  4024.         CALL    AllocSignal,_SysBase(PC)
  4025.         moveq   #0,d1
  4026.         bset    d0,d1
  4027.         move.l  d1,mysignal
  4028.         rts
  4029.  
  4030. ;remove handler
  4031. removeh     movea.l InRequest(PC),a1
  4032.         move.l  #InInterrupt,40(a1)
  4033.         move.w  #10,28(a1)
  4034.         CALL    DoIO,_SysBase(PC)
  4035.         movea.l InRequest(PC),a1
  4036.         CALL    CloseDevice,_SysBase(PC)
  4037.         move.l  InRequest,-(a7)
  4038.         LIBCALL DeleteStdIO
  4039.         addq    #4,a7
  4040.         move.l  InputMsg,-(a7)
  4041.         LIBCALL DeletePort
  4042.         addq    #4,a7
  4043.         rts
  4044.  
  4045. ;this is the handler, it checks if amiga-amiga-x
  4046. ;has been pressed and signals it to our task
  4047. Keyhandler  tst.b   running
  4048.         bne.s   endhandler
  4049.         cmp.b   #1,4(a0)
  4050.         bne.s   endhandler
  4051.         move.w  8(a0),d0
  4052.         andi.w  #$c0,d0
  4053.         cmpi.w  #$c0,d0
  4054.         bne.s   endhandler
  4055.         cmp.w   #$32,6(a0)
  4056.         bne.s   endhandler
  4057. wakeup        move.l  a0,-(a7)
  4058.         movea.l mytask(PC),a1
  4059.         move.l  mysignal(PC),d0
  4060.         CALL    Signal,_SysBase(PC)
  4061.         move.l  (a7)+,a0
  4062.         clr.b   4(a0)
  4063. endhandler  move.l  a0,d0
  4064.         rts
  4065.  
  4066. snoop        bsr     cls
  4067.         bsr     nodenam
  4068.         moveq   #1,d7
  4069.         lea     TReNode(PC),a4
  4070.         bsr     findnam
  4071.         tst.b   d7
  4072.         bne.s   1$
  4073.         move.l  #stperr,d0
  4074.         bra     putnam
  4075. 1$        move.l  d0,captask
  4076.         pea     0
  4077.         pea     memportname
  4078.         LIBCALL CreatePort
  4079.         addq    #8,a7
  4080.         move.l  d0,snoopport
  4081.         beq     tm6
  4082.  
  4083.         bsr     replyintui
  4084.         move.b  #1,addlines
  4085.         lea     snoophead(PC),a0
  4086.         bsr     puthead
  4087.         move.l  _SysBase(PC),a1
  4088.         move.l  -196(a1),oldalloc
  4089.         move.l  -208(a1),oldfree
  4090.         move.l  #capmalloc,d0
  4091.         move.l  #-198,a0
  4092.         CALL    SetFunction,_SysBase(PC)
  4093.         move.l  _SysBase(PC),a1
  4094.         move.l  #capmfree,d0
  4095.         move.l  #-210,a0
  4096.         CALL    SetFunction,_SysBase(PC)
  4097.         clr.b   bool
  4098.         clr.b   cbreak
  4099.  
  4100. waitmem     move.l  snoopport(PC),a0
  4101.         moveq   #0,d1
  4102.         move.b  15(a0),d1
  4103.         bset    d1,d0
  4104.         move.l  d0,auxsig
  4105.         bsr     processmsgs
  4106.  
  4107. tm7        move.l  mytask(PC),a0
  4108.         move.l  snoopport(PC),a0
  4109.         CALL    GetMsg,_SysBase(PC)
  4110.         tst.l   d0
  4111.         bne     tm8
  4112.         tst.b   cbreak
  4113.         bne     snoopend
  4114.         bra     waitmem
  4115. tm8        move.l  d0,a3
  4116.         move.l  20(a3),d3
  4117.         btst    #31,d3
  4118.         beq     freed
  4119.         move.l  #allok,d0
  4120.         bsr     putstr
  4121.         lea     memname(PC),a2
  4122.         lea     membit(PC),a4
  4123.         moveq   #4,d5
  4124. tm2        move.l  0(a4),d4
  4125.         btst    d4,d3
  4126.         beq.s   tm1
  4127.         move.l  0(a2),d0
  4128.         bsr     putstr
  4129. tm1        addq    #4,a2
  4130.         addq    #4,a4
  4131.         dbf     d5,tm2
  4132.         moveq   #26,d1
  4133.         bsr     tab
  4134.         move.l  24(a3),d0
  4135.         move.l  d0,d3
  4136.         bsr     hexa
  4137.         move.l  28(a3),d0
  4138.         bne.s   tm3
  4139.         move.l  #failed,d0
  4140.         bsr     putstr
  4141.         moveq   #53,d1
  4142.         bsr     tab
  4143.         bra     tm4
  4144. tm3        bsr     hexa
  4145.         move.l  28(a3),d0
  4146.         add.l   d3,d0
  4147.         bsr     hexa
  4148.         bra     tm4
  4149.  
  4150. freed        move.l  #free,d0
  4151.         bsr     putstr
  4152.         move.b  #'-',d0
  4153.         moveq   #18,d1
  4154. tm9        bsr     putchar
  4155.         dbf     d1,tm9
  4156.         move.b  #' ',d0
  4157.         bsr     putchar
  4158.         move.l  d3,d0
  4159.         bsr     hexa
  4160.         move.l  24(a3),d0
  4161.         bsr     hexa
  4162.         move.l  24(a3),d0
  4163.         add.l   d3,d0
  4164.         bsr     hexa
  4165.  
  4166. tm4        move.l  32(a3),d0
  4167.         bsr     hexa
  4168.         bsr     newline
  4169.         move.w  18(a3),d0
  4170.         ext.l   d0
  4171.         move.l  a3,a1
  4172.         CALL    FreeMem,_SysBase(PC)
  4173.         bra     tm7
  4174.  
  4175. snoopend    move.l  _SysBase(PC),a1
  4176.         move.l  oldalloc(PC),d0
  4177.         move.l  #-198,a0
  4178.         CALL    SetFunction,_SysBase(PC)
  4179.         move.l  _SysBase(PC),a1
  4180.         move.l  oldfree,d0
  4181.         move.l  #-210,a0
  4182.         CALL    SetFunction,_SysBase(PC)
  4183.         move.l  snoopport,-(a7)
  4184.         LIBCALL DeletePort
  4185.         addq    #4,a7
  4186.         move.l  #stoped,d0
  4187.         bsr     putnam
  4188.         clr.b   addlines
  4189.         clr.l   auxsig
  4190. tm6        rts
  4191.  
  4192. memname     dc.l    memlarg,memclr,memfast,memchip,mempubl
  4193. membit        dc.l    17,16,2,1,0
  4194.  
  4195. capmalloc   movem.l d0-d7/a0-a6,-(a7)
  4196.         move.l  _SysBase(PC),a6
  4197.         move.l  276(a6),d4
  4198.         cmp.l   captask(PC),d4
  4199.         bne.s   capm1
  4200.         tst.b   bool
  4201.         bne     capm1
  4202.         move.b  #1,bool
  4203.         moveq   #36,d6
  4204.         bsr     allocmsg
  4205.         beq     capm2
  4206.         bset    #31,d1
  4207.         move.l  d1,20(a5)
  4208.         move.l  d0,24(a5)
  4209.         move.l  60(a7),32(a5)
  4210.         move.l  a5,remembr
  4211.         movem.l (a7)+,d0-d7/a0-a6
  4212.         bsr     memalloc
  4213.         movem.l d0-d7/a0-a6,-(a7)
  4214.         move.l  remembr(PC),a1
  4215.         move.l  d0,28(a1)
  4216.         move.l  snoopport,a0
  4217.         move.b  #5,8(a1)
  4218.         CALL    PutMsg,_SysBase(PC)
  4219.         clr.b   bool
  4220.         movem.l (a7)+,d0-d7/a0-a6
  4221.         rts
  4222. capm2        clr.b   bool
  4223. capm1        movem.l (a7)+,d0-d7/a0-a6
  4224. memalloc    dc.w    $4ef9
  4225. oldalloc    dc.l    0
  4226.  
  4227. capmfree    movem.l d0-d7/a0-a6,-(a7)
  4228.         move.l  _SysBase(PC),a6
  4229.         move.l  276(a6),d4
  4230.         cmp.l   captask(PC),d4
  4231.         bne.s   capf1
  4232.         tst.b   bool
  4233.         bne.s   capf1
  4234.         move.b  #1,bool
  4235.         moveq   #36,d6
  4236.         bsr     allocmsg
  4237.         beq.s   capf2
  4238.         move.l  d0,20(a5)
  4239.         move.l  a1,24(a5)
  4240.         move.l  60(a7),32(a5)
  4241.         move.l  snoopport,a0
  4242.         move.b  #5,8(a5)
  4243.         move.l  a5,a1
  4244.         CALL    PutMsg,_SysBase(PC)
  4245. capf2        clr.b   bool
  4246. capf1        movem.l (a7)+,d0-d7/a0-a6
  4247.         dc.w    $4ef9
  4248. oldfree     dc.l    0
  4249.  
  4250. allocmsg    movem.l d0-d1/a0-a1,-(a7)
  4251.         move.l  d6,d0
  4252.         move.l  #65536,d1
  4253.         bsr     memalloc
  4254.         tst.l   d0
  4255.         beq.s   alm1
  4256.         move.l  d0,a5
  4257.         move.w  d6,18(a5)
  4258. alm1        movem.l (a7)+,d0-d1/a0-a1
  4259.         move.l  a5,d6
  4260.         rts
  4261.  
  4262. myswitch    movem.l d0-d1/a0-a1,-(a7)
  4263.         move.l  _SysBase(PC),a0
  4264.         move.l  276(a0),d0
  4265.         move.l  tasksnum(PC),d1
  4266.         lea     cputime,a0
  4267.         subq.l  #1,d1
  4268.         bmi.s   swadd
  4269. sw0        cmp.l   (a0)+,d0
  4270.         dbeq    d1,sw0
  4271.         tst     d1
  4272.         bmi.s   swadd
  4273. swi1        add.l   #1,508(a0)
  4274. swgo        movem.l (a7)+,d0-d1/a0-a1
  4275.         dc.w    $4ef9
  4276. oldswitch   dc.l    0
  4277. swadd        cmp.l   #125,tasksnum
  4278.         bge.s   swgo
  4279.         addq.l  #1,tasksnum
  4280.         move.l  d0,0(a0)
  4281.         move.l  #1,512(a0)
  4282.         bra.s   swgo
  4283.  
  4284. countio     addq.l #1,iocount
  4285.         moveq  #0,d0
  4286. cio1        rts
  4287.  
  4288. iconbackdrp tst.b   iconifyon
  4289.         beq.s   1$
  4290.         lea     icnwindow,a0
  4291.         eor.l   #$100,14(a0)    ;wn_Flags
  4292. 1$        rts
  4293.  
  4294. iconifyoff  tst.b   iconifyon
  4295.         beq.s   cio1
  4296.         clr.b   iconifyon
  4297.         tst.b   fromfile
  4298.         bne.s   1$
  4299.         move.l  wnptr(PC),d0
  4300.         beq.s   1$
  4301.         move.l  d0,a0
  4302.         lea     iconifgad,a1
  4303.         CALL    RemoveGadget,intuibase(PC)
  4304.         move.l  wnptr(PC),a0
  4305.         CALL    RefreshWindowFrame,intuibase(PC)
  4306. 1$        move.l  #iconify,d0
  4307.  
  4308. killseg     movem.l d1-d2/a0-a4,-(a7)
  4309.         subq    #4,d0
  4310.         move.l  4,a6
  4311.         move.l  276(a6),a4
  4312.         move.l  128(a4),d1
  4313.         lsl.l   #2,d1
  4314.         move.l  d1,a3
  4315.         move.l  12(a3),d1
  4316.         bne.s   2$
  4317.         move.l  172(a4),d1
  4318.         lsl.l   #2,d1
  4319.         move.l  d1,a4
  4320.         move.l  60(a4),d1
  4321.  
  4322. 2$        lsl.l   #2,d1
  4323.         cmp.l   d0,d1
  4324.         beq.s   4$
  4325.         move.l  d1,a4
  4326.         move.l  0(a4),d1
  4327.         beq.s   5$
  4328.         bra.s   2$
  4329.  
  4330. 4$        move.l  d1,a0
  4331.         move.l  0(a0),0(a4)
  4332.         clr.l   0(a0)
  4333.         lsr.l   #2,d1
  4334.         CALL    UnLoadSeg,dosbase(PC)
  4335.         movem.l (a7)+,d1-d2/a0-a4
  4336. 5$        rts
  4337.  
  4338. alert        bsr     stoptimer
  4339.         move.l  excpttask(PC),d0
  4340.         bne.s   alert1
  4341.         move.l  #noguru,d0
  4342.         bra     putnam
  4343. alert1        move.l  #softfail,d0
  4344.         bsr     putstr
  4345.         move.l  excpttask(PC),a0
  4346.         move.l  10(a0),d0
  4347.         bsr     putnam
  4348.         cmp.l   #3,excpterror
  4349.         bne.s   1$
  4350.         move.l  #addrserr,d0
  4351.         bsr     putstr
  4352.         move.l  excptaddr(PC),d0
  4353.         bsr     hexa
  4354.         bsr     newline
  4355. 1$        move.l  #procount,d0
  4356.         bsr     putstr
  4357.         move.l  excptpc(PC),d0
  4358.         bsr     hexa
  4359.         bsr     newline
  4360.         move.l  #gurutxt,d0
  4361.         bsr     putstr
  4362.         move.l  excpterror(PC),d0
  4363.         bsr     hexa
  4364.         lea     out,a0
  4365.         move.l  ptr(PC),d0
  4366.         move.b  #'.',-1(a0,d0)
  4367.         move.l  excpttask(PC),d0
  4368.         bsr     hexa
  4369.         bra     newline
  4370.  
  4371. showguru    bsr     alert
  4372.         tst.b   ownscreen
  4373.         bne.s   5$
  4374.         move.l  wnptr(PC),a0
  4375.         CALL    WindowToFront,intuibase(PC)
  4376.         bra.s   2$
  4377. 5$        move.l  screenptr,a0
  4378.         CALL    ScreenToFront,intuibase(PC)
  4379. 2$        move.l  #whatnow,d0
  4380.         bsr     putnam
  4381.         clr.l   oldpageend
  4382.         bsr     readline
  4383.  
  4384.         cmp.b   #'i',inputbuffer
  4385.         beq.s   4$
  4386. 1$        cmp.b   #'k',inputbuffer
  4387.         bne.s   2$
  4388.         move.l  excpttask(PC),a1
  4389.         tst.l   22(a1)
  4390.         bne.s   3$
  4391.         CALL    RemTask,_SysBase(PC)
  4392.         bra.s   4$
  4393. 3$        move.l  a1,d0
  4394.         bsr     canok
  4395. 4$        clr.l   lastprinted
  4396.         rts
  4397.  
  4398. myaddtask   move.l  a3,-(a7)
  4399.         lea     mytrap(PC),a3
  4400.         move.l  50(a1),d0
  4401.         beq.s   1$
  4402.         cmp.l   oldtrap(PC),d0
  4403.         beq.s   1$
  4404.         lea     myproctrap(PC),a3
  4405.         cmp.l   oldproctrap(PC),d0
  4406.         bne.s   2$
  4407. 1$        move.l  a3,50(a1)
  4408. 2$        move.l  (a7)+,a3
  4409.         dc.w    $4ef9
  4410. OldAddTask  dc.l    0
  4411.  
  4412. myproctrap  bsr     traphandle
  4413.         dc.w    $4ef9
  4414. oldproctrap dc.l    0
  4415.  
  4416. mytrap        bsr     traphandle
  4417.         moveq   #0,d0
  4418.         CALL    Wait,_SysBase(PC)
  4419.         dc.w    $4ef9
  4420. oldtrap     dc.l    0
  4421.  
  4422. traphandle  movem.l d0-d7/a0-a6,$180
  4423.         move.l  4,a6
  4424.         move.l  276(a6),excpttask
  4425.         move.l  4(a7),d0
  4426.         cmp.l   #9,d0
  4427.         beq.s   2$
  4428.         move.l  d0,excpterror
  4429.         moveq   #10,d1
  4430.         cmp.l   #3,d0
  4431.         bne.s   1$
  4432.         move.l  0(a7,d1.w),excptaddr
  4433.         moveq   #18,d1
  4434. 1$        move.l  0(a7,d1.w),excptpc
  4435.         move.l  mytask(PC),a1
  4436.         move.l  trapsignal(PC),d0
  4437.         jsr     _LVOSignal(a6)
  4438. 2$        movem.l $180,d0-d7/a0-a6
  4439.         rts
  4440.  
  4441. trapguru    tst.b   wanttraps
  4442.         bne     restoretrap
  4443.         move.b  #1,wanttraps
  4444.  
  4445. addtraps    tst.b   wanttraps
  4446.         beq     5$
  4447.         move.l  304(a6),oldtrap         ;Original EXEC trap handler
  4448.         moveq   #-1,d0
  4449.         CALL    AllocSignal,_SysBase(PC)
  4450.         moveq   #0,d1
  4451.         bset    d0,d1
  4452.         move.l  d1,trapsignal
  4453.         move.l  #_LVOAddTask,a0        ;need a new AddTask() to change
  4454.         move.l  2(a6,a0),OldAddTask     ;AmigaDos's default trap handler
  4455.         move.l  a6,a1
  4456.         move.l  #myaddtask,d0
  4457.         CALL    SetFunction,_SysBase(PC)
  4458.         CALL    Forbid,_SysBase(PC)     ;change the trap handler of
  4459.         moveq   #0,d5            ;aleady running tasks
  4460.         bsr     getaskdat            ;get task stucture pointers
  4461. 1$        tst.b   entries
  4462.         beq.s   2$
  4463.         lea     -16(a5),a5
  4464.         move.l  0(a5),a4                ;pointer to a task structure
  4465.         lea     myproctrap(PC),a0
  4466.         move.l  50(a4),d0               ;Task->tc_TrapCode
  4467.         cmp.l   oldproctrap(PC),d0      ;AmigaDos Handler ?
  4468.         beq.s   3$
  4469.         lea     mytrap(PC),a0           ;EXEC Handler ?
  4470.         cmp.l   oldtrap(PC),d0
  4471.         bne.s   4$                ;must be a custom one, skip it
  4472. 3$        move.l  a0,50(a4)               ;replace it
  4473. 4$        subq.b  #1,entries
  4474.         bra.s   1$
  4475. 2$        CALL    Permit,_SysBase(PC)
  4476. 5$        rts
  4477.  
  4478. restoretrap tst.b   wanttraps
  4479.         beq.s   6$
  4480.         tst.b   fromfile
  4481.         bne.s   5$
  4482.         move.l  #_LVOAddTask,a0
  4483.         move.l  OldAddTask(PC),d0
  4484.         move.l  _SysBase(PC),a1
  4485.         CALL    SetFunction,_SysBase(PC)
  4486.         CALL    Forbid,_SysBase(PC)
  4487.         bsr     getaskdat
  4488. 1$        tst.b   entries
  4489.         beq.s   2$
  4490.         lea     -16(a5),a5
  4491.         move.l  0(a5),a4
  4492.         move.l  oldproctrap(PC),a0
  4493.         move.l  50(a4),d0
  4494.         cmp.l   #myproctrap,d0
  4495.         beq.s   3$
  4496.         move.l  oldtrap(PC),a0
  4497.         cmp.l   #mytrap,d0
  4498.         bne.s   4$
  4499. 3$        move.l  a0,50(a4)
  4500. 4$        subq.b  #1,entries
  4501.         bra.s   1$
  4502. 2$        CALL    Permit,_SysBase(PC)
  4503.         clr.l   trapsignal
  4504. 5$        clr.b   wanttraps
  4505. 6$        rts
  4506.  
  4507. ;save the contents of the output buffer
  4508. ;to a file
  4509. saveoutput  bsr     nodenam2
  4510.         tst.b   0(a5)
  4511.         beq     syntax
  4512.         move.l  a5,d1
  4513.         move.l  #1006,d2
  4514.         CALL    Open,dosbase(PC)
  4515.         move.l  d0,d5
  4516.         bne.s   1$
  4517.         move.l  #openerr,d0
  4518.         bsr     putstr
  4519.         move.l  a5,d0
  4520.         bra     putnam
  4521. 1$        move.l  outchain(PC),d0
  4522.         beq.s   3$
  4523. 2$        move.l  d0,a5
  4524.         move.w  12(a5),d3
  4525.         beq.s   4$
  4526.         ext.l   d3
  4527.         lea     14(a5),a1
  4528.         move.l  a1,d2
  4529.         move.l  d5,d1
  4530.         CALL    Write,dosbase(PC)
  4531.         tst.l   d0
  4532.         ble.s   3$
  4533. 4$        moveq   #1,d3
  4534.         move.l  d5,d1
  4535.         move.l  #cr,d2
  4536.         CALL    Write,dosbase(PC)
  4537.         tst.l   d0
  4538.         ble.s   3$
  4539.         move.l  0(a5),d0
  4540.         bne.s   2$
  4541. 3$        move.l  d5,d1
  4542.         CALL    Close,dosbase(PC)
  4543.         rts
  4544.  
  4545. grabtimerio lea     tiohead(PC),a0
  4546.         bsr     puthead
  4547.         move.b  timeout(PC),d4
  4548.         move.b  #255,timeout
  4549.         bsr     starttimer
  4550.         move.b  d4,timeout
  4551.         lea     timerio,a1
  4552.         CALL    Disable,_SysBase(PC)
  4553. 2$        move.l  0(a1),d2
  4554.         beq.s   1$
  4555.         move.l  d2,a1
  4556.         bra.s   2$
  4557. 1$        CALL    Enable,_SysBase(PC)
  4558.         lea     -4(a1),a5
  4559.         bsr     stoptimer
  4560.         lea     buffer,a4
  4561.         moveq   #1,d4
  4562.         bsr     gettrq
  4563.  
  4564.         lea     timerio,a0
  4565.         lea     dummy,a1
  4566.         moveq   #40,d0
  4567.         CALL    CopyMem,_SysBase(PC)
  4568.  
  4569.         lea     dummy,a1
  4570.         lea     timernam(PC),a0
  4571.         moveq   #0,d1
  4572.         moveq   #0,d0
  4573.         CALL    OpenDevice,_SysBase(PC)
  4574.  
  4575.         lea     dummy,a1
  4576.         move.l  #1<<30,32(a1)
  4577.         CALL    SendIO,_SysBase(PC)
  4578.  
  4579.         lea     dummy,a5
  4580.         CALL    Disable,_SysBase(PC)
  4581. 8$        move.l  0(a5),d2
  4582.         beq.s   7$
  4583.         move.l  d2,a5
  4584.         bra.s   8$
  4585. 7$        CALL    Enable,_SysBase(PC)
  4586.         lea     -4(a5),a5
  4587.  
  4588.         lea     dummy,a1
  4589.         CALL    AbortIO,_SysBase(PC)
  4590.         lea     timerio,a1
  4591.         CALL    WaitIO,_SysBase(PC)
  4592.         move.w  timersig,d0
  4593.         moveq   #0,d1
  4594.         bset    d0,d1
  4595.         moveq   #0,d0
  4596.         CALL    SetSignal,_SysBase(PC)
  4597.  
  4598.         moveq   #0,d4
  4599.         bsr     gettrq
  4600.  
  4601.         lea     dummy,a1
  4602.         CALL    CloseDevice,_SysBase(PC)
  4603.  
  4604.         clr.l   (a4)+
  4605.         lea     -22(a4),a2
  4606.         moveq   #18,d2
  4607.         bsr     sortlist
  4608.  
  4609.         lea     buffer,a5
  4610. 5$        move.l  (a5)+,d0
  4611.         beq.s   6$
  4612.         bsr     hexa
  4613.         move.w  (a5)+,d0
  4614.         ext.l   d0
  4615.         mulu    #9,d0
  4616.         add.l   #timerunits,d0
  4617.         bsr     putstr
  4618.         move.l  (a5)+,d3
  4619.         mulu    #10,d3
  4620.         move.l  (a5)+,d0
  4621.         move.l  #100000,d1
  4622.         bsr     div
  4623.         add.l   d3,d0
  4624.         cmp.l   #2559,d0
  4625.         ble.s   9$
  4626.         move.l  #whatsthis,d0
  4627.         bsr     putstr
  4628.         bra.s   10$
  4629. 9$        moveq   #1,d6
  4630.         bsr     putfrac
  4631. 10$        move.b  #' ',d0
  4632.         bsr     putchar
  4633.         move.l  (a5)+,d0
  4634.         bsr     getaskname2
  4635.         bsr     newline
  4636.         bra.s   5$
  4637. 6$        rts
  4638.  
  4639. gettrq        CALL    Disable,_SysBase(PC)
  4640. 3$        move.l  0(a5),a5
  4641.         tst.l   0(a5)
  4642.         beq.s   4$
  4643.         move.l  a5,(a4)+
  4644.         move.w  d4,(a4)+
  4645.         move.l  32(a5),(a4)+
  4646.         move.l  36(a5),(a4)+
  4647.         move.l  14(a5),a1
  4648.         move.l  16(a1),(a4)+
  4649.         bra.s   3$
  4650. 4$        CALL    Enable,_SysBase(PC)
  4651.         rts
  4652.  
  4653.  
  4654. ;check if the timer is runnig, start it if not
  4655. starttimer  lea     timerio,a1
  4656.         cmp.b   #5,8(a1)
  4657.         beq.s   1$
  4658.         moveq   #0,d0
  4659.         move.b  timeout(PC),d0
  4660.         bne.s   2$
  4661.         tst.l   timeoutm
  4662.         beq.s   1$
  4663. 2$        move.l  d0,32(a1)
  4664.         move.l  timeoutm(PC),36(a1)
  4665.         move.w  #9,28(a1)
  4666.         CALL    SendIO,_SysBase(PC)
  4667. 1$        rts
  4668. ;Abort a timer request, if pending
  4669. stoptimer   lea     timerio,a1
  4670.         cmp.b   #5,8(a1)
  4671.         bne.s   1$
  4672.         CALL    AbortIO,_SysBase(PC)
  4673.         lea     timerio,a1
  4674.         CALL    WaitIO,_SysBase(PC)
  4675. 1$        move.w  timersig,d0
  4676.         moveq   #0,d1
  4677.         bset    d0,d1
  4678.         moveq   #0,d0
  4679.         CALL    SetSignal,_SysBase(PC)
  4680.         rts
  4681. ;Xoper main loop, process all incoming messages
  4682. processmsgs move.l  wnptr(PC),a0
  4683.         moveq   #0,d0
  4684.         move.w  intuisig(PC),d1
  4685.         bset    d1,d0
  4686.         move.w  timersig(PC),d1
  4687.         bset    d1,d0
  4688.         or.w    #4096,d0
  4689.         or.l    auxsig(PC),d0
  4690.         tst.l   auxsig
  4691.         bne.s   1$
  4692.         or.l    trapsignal(PC),d0
  4693. 1$        CALL    Wait,_SysBase(PC)
  4694.  
  4695.         move.l  d0,tasksigs
  4696.  
  4697.         move.l  trapsignal(PC),d1
  4698.         and.l   d0,d1
  4699.         beq.s   ctrl_c
  4700.         tst.b   gotguru
  4701.         bne.s   ctrl_c
  4702.         move.b  #1,gotguru
  4703.         bsr     showguru
  4704.         clr.b   gotguru
  4705.  
  4706. ctrl_c        moveq   #12,d1
  4707.         bsr     testsig
  4708.         bne     exit
  4709.  
  4710.  
  4711. timermsg    move.w  timersig(PC),d1
  4712.         bsr     testsig
  4713.         beq     intuimsgs
  4714.         tst.w   repeat
  4715.         bne.s   1$
  4716.         bsr     showwhat
  4717.         bra.s   intuimsgs
  4718. 1$        move.w  repeatlen,d0
  4719.         lea     repeatbuffer,a2
  4720.         lea     dummy,a1
  4721.         move.w  d0,d1
  4722. 2$        move.b  (a2)+,(a1)+
  4723.         dbf     d1,2$
  4724.         bsr     cli
  4725.         bsr     starttimer
  4726.  
  4727. intuimsgs   move.w  intuisig(PC),d1
  4728.         bsr     testsig
  4729.         beq     processnxtmsg
  4730. nextimsg    move.l  wnptr(PC),a0
  4731.         move.l  $56(a0),a0
  4732.         CALL    GetMsg,_SysBase(PC)
  4733.         tst.l   d0
  4734.         beq     processnxtmsg
  4735.         move.l  d0,intuimsg
  4736.  
  4737.         move.l  d0,a0
  4738.         move.l  20(a0),d0
  4739.  
  4740.         cmp.l   #$200,d0        ;CloseWindow
  4741.         bne.s   1$
  4742.         tst.b   addlines
  4743.         beq     exitall
  4744.         move.b  #1,cbreak
  4745.         bra     intuiend
  4746.  
  4747. 1$        cmp.l   #2,d0        ;ResizeWindow
  4748.         bne.s   2$
  4749.         bsr     setupscreen
  4750.         bra     intuiend
  4751.  
  4752. 2$        cmp.l   #4,d0        ;refresh
  4753.         bne.s   22$
  4754.         bsr     putiline
  4755.         bsr     blastout
  4756.         bsr     UpdateIArea
  4757.         bra     intuiend
  4758.  
  4759. 22$        tst.b   addlines
  4760.         bne     3$
  4761.         cmp.l   #$40,d0        ;gadgetup
  4762.         bne.s   3$
  4763.         tst.w   getanswer
  4764.         bne.s   3$
  4765.         bsr     replyintui
  4766.         bsr     stoptimer
  4767.         bra     instback
  4768.  
  4769. 3$        cmp.l   #$400,d0        ;RawKey
  4770.         bne     notarawkey
  4771.         move.w  #$80,d0
  4772.         and.w   24(a0),d0
  4773.         bne     intuiend
  4774.         and.w   #$7f,24(a0)
  4775.         lea     ievent,a1
  4776.         move.b  #1,4(a1)
  4777.         move.l  24(a0),6(a1)
  4778.         move.w  26(a0),qualifier
  4779.         move.l  a1,a0
  4780.         lea     outevent,a1
  4781.         moveq   #20,d1
  4782.         suba.l  a2,a2
  4783.         CALL    RawKeyConvert,condev(PC)
  4784.         tst.l   d0
  4785.         beq     intuiend
  4786.         lea     inputbuffer,a1
  4787.         lea     outevent,a2
  4788.         move.w  curpos(PC),d4
  4789.         moveq   #0,d3
  4790.         tst.b   addlines
  4791.         bne     197$
  4792.  
  4793.         sub.w   #1,cmdcompflag
  4794.  
  4795.         cmp.b   #$9b,0(a2)          ;CSI
  4796.         bne     110$
  4797.  
  4798.         cmp.b   #'?',1(a2)          ;help
  4799.         bne.s   399$
  4800.         tst.w   getanswer
  4801.         bne.s   399$
  4802.         bsr     stoptimer
  4803.         tst.w   bottomin
  4804.         bne.s   398$
  4805.         move.w  #1,bottomin
  4806.         clr.w   ibufferlen
  4807.         clr.w   curpos
  4808.         bsr     UpdateIArea
  4809. 398$        move.l  #usetxt,d0
  4810.         bsr     putnam
  4811.         clr.l   lastprinted
  4812.         bsr     blastout
  4813.         bra.s   420$
  4814.  
  4815. 399$        cmp.b   #'C',1(a2)          ;cursor right
  4816.         bne.s   400$
  4817.         cmp.w   ibufferlen(PC),d4
  4818.         bge.s   420$
  4819.         addq    #1,d4
  4820. 421$        move.w  d4,curpos
  4821. 420$        bra     100$
  4822.  
  4823. 400$        cmp.b   #'D',1(a2)          ;cursor left
  4824.         bne.s   401$
  4825.         subq    #1,d4
  4826.         bpl.s   421$
  4827.         bra.s   420$
  4828.  
  4829. 401$        cmp.b   #' ',1(a2)
  4830.         bne.s   402$
  4831.  
  4832.         cmp.b   #'@',2(a2)          ;shift right
  4833.         bne.s   403$
  4834.  
  4835. 404$        cmp.w   ibufferlen(PC),d4
  4836.         bge.s   421$
  4837.         addq    #1,d4
  4838.         cmp.b   #' ',0(a1,d4)
  4839.         bne.s   404$
  4840. 405$        cmp.w   ibufferlen(PC),d4
  4841.         bge.s   421$
  4842.         addq    #1,d4
  4843.         cmp.b   #' ',0(a1,d4)
  4844.         beq.s   405$
  4845.         bra.s   421$
  4846.  
  4847. 403$        cmp.b   #'A',2(a2)          ;shift left
  4848.         bne.s   420$
  4849. 406$        tst.w   d4
  4850.         beq.s   421$
  4851.         subq    #1,d4
  4852.         cmp.b   #' ',0(a1,d4)
  4853.         beq.s   406$
  4854. 407$        tst.w   d4
  4855.         beq.s   421$
  4856.         subq    #1,d4
  4857.         cmp.b   #' ',0(a1,d4)
  4858.         bne.s   407$
  4859.         addq    #1,d4
  4860.         bra.s   421$
  4861.  
  4862. 402$        cmp.b   #'A',1(a2)          ;cursor up
  4863.         bne.s   408$
  4864.         tst.w   bottomin
  4865.         bne.s   480$
  4866.         tst.w   curpos
  4867.         bne.s   480$
  4868.  
  4869.         clr.w   curpos
  4870.         clr.w   ibufferlen
  4871.         bsr     UpdateIArea
  4872.         bsr     clrcursor
  4873.         move.w  edline(PC),d3
  4874.         ext.l   d3
  4875.         tst.w   d3
  4876.         beq.s   481$
  4877.         subq    #1,d3
  4878.         cmp.l   firstline(PC),d3
  4879.         bge.s   481$
  4880.         move.l  d3,-(a7)
  4881.         subq.l  #1,firstline
  4882.         bsr     blastout
  4883.         move.l  (a7)+,d3
  4884. 481$        move.w  d3,edline
  4885.         bsr     getcurpos
  4886.         bsr     putcursor
  4887.         bra     intuiend
  4888. 480$        move.l  history(PC),a0
  4889.         tst.l   0(a0)
  4890.         beq.s   423$
  4891.         move.l  curhist(PC),a1
  4892.         cmp.l   a0,a1
  4893.         beq.s   409$
  4894.         move.l  4(a1),d0
  4895.         move.l  d0,curhist
  4896. 409$        move.l  a1,gothline
  4897.         bsr     copyhistory
  4898. 423$        bra     100$
  4899.  
  4900. 408$        cmp.b   #'B',1(a2)          ;cursor down
  4901.         bne     410$
  4902.         tst.w   bottomin
  4903.         bne.s   414$
  4904.         tst.w   curpos
  4905.         bne.s   414$
  4906.  
  4907.         clr.w   curpos
  4908.         clr.w   ibufferlen
  4909.         bsr     UpdateIArea
  4910.         bsr     clrcursor
  4911.         move.w  edline(PC),d3
  4912.         ext.l   d3
  4913.         move.l  numlines(PC),d4
  4914.         subq    #1,d4
  4915.         cmp.l   d4,d3
  4916.         beq.s   490$
  4917.         move.l  firstline(PC),d2
  4918.         add.w   rows(PC),d2
  4919.         subq    #1,d2
  4920.         addq    #1,d3
  4921.         cmp.w   d2,d3
  4922.         ble.s   490$
  4923.         move.l  d3,-(a7)
  4924.         addq.l  #1,firstline
  4925.         bsr     blastout
  4926.         move.l  (a7)+,d3
  4927. 490$        bra     481$
  4928. 414$        move.l  curhist(PC),d0
  4929.         beq.s   423$
  4930.         move.l  d0,a1
  4931.         move.l  0(a1),a1
  4932.         tst.l   0(a1)
  4933.         bne.s   411$
  4934.         clr.l   gothline
  4935.         clr.w   curpos
  4936.         clr.w   ibufferlen
  4937.         bra     423$
  4938. 411$        move.l  a1,curhist
  4939.         bra     409$
  4940.  
  4941. 410$        cmp.b   #'T',1(a2)          ;shift up
  4942.         bne.s   412$
  4943.         tst.w   hnum
  4944.         beq     423$
  4945.         move.l  history(PC),a1
  4946.         move.l  a1,curhist
  4947.         bra     409$
  4948.  
  4949. 412$        cmp.b   #'S',1(a2)          ;shift down
  4950.         bne.s   440$
  4951.         tst.w   hnum
  4952.         beq     423$
  4953.         move.l  history+8,curhist
  4954.         bra.s   414$
  4955.  
  4956. 440$        cmp.b   #'0',1(a2)          ;function keys
  4957.         bmi     423$
  4958.         cmp.b   #'9',1(a2)
  4959.         bgt     423$
  4960.         lea     1(a2),a0
  4961.         bsr     getnum
  4962.         lea     fkeys(PC),a0
  4963. 441$        move.l  0(a0),a0
  4964.         tst.l   0(a0)
  4965.         beq     100$
  4966.         cmp.b   8(a0),d2
  4967.         bne.s   441$
  4968.  
  4969.         move.b  9(a0),d5
  4970.         ext.w   d5
  4971.         subq    #1,d5
  4972.         lea     10(a0),a0
  4973.         move.w  curpos(PC),d4
  4974.         lea     inputbuffer,a2
  4975.         moveq   #0,d3
  4976.         lea     0(a2,d4),a2
  4977. 445$        move.b  (a0)+,d0
  4978.         cmp.b   #'^',d0
  4979.         bne.s   442$
  4980.         moveq   #1,d3
  4981.         bra.s   443$
  4982. 442$        cmp.b   #'_',d0
  4983.         bne.s   444$
  4984.         move.b  #' ',d0
  4985. 444$        move.b  d0,(a2)+
  4986.         addq    #1,d4
  4987. 443$        dbf     d5,445$
  4988.         move.w  d4,curpos
  4989.         cmp.w   ibufferlen(PC),d4
  4990.         ble.s   446$
  4991.         move.w  d4,ibufferlen
  4992. 446$        tst     d3
  4993.         beq     100$
  4994.         bra     got_fkey
  4995.  
  4996. 110$        moveq   #0,d3
  4997. 101$        move.w  curpos(PC),d4
  4998.         tst     d0
  4999.         beq     100$
  5000.         cmp.b   #13,0(a2,d3)        ;return
  5001.         beq     got_enter
  5002.  
  5003.         cmp.b   #27,0(a2,d3)        ;esc
  5004.         bne     799$
  5005.         tst.w   getanswer
  5006.         bne     100$
  5007.         clr.b   insmode
  5008.         clr.w   ibufferlen
  5009.         move.w  #200,curpos
  5010.         bsr     UpdateIArea
  5011.         clr.w   curpos
  5012.         tst.w   bottomin
  5013.         bne.s   700$
  5014.         move.w  #1,bottomin
  5015.         bsr     getcurpos
  5016.         cmp.b   #5,timerstate
  5017.         bne.s   765$
  5018.         bsr     starttimer
  5019. 765$        bra     100$
  5020.  
  5021. 700$        move.b  timerio+8,timerstate
  5022.         bsr     stoptimer
  5023.         move.w  edline(PC),d0
  5024.         move.l  firstline(PC),d4
  5025.         cmp.w   d4,d0
  5026.         bmi.s   701$
  5027.         move.w  d4,d5
  5028.         add.w   rows(PC),d5
  5029.         cmp.w   d5,d0
  5030.         bmi.s   702$
  5031. 701$        move.w  rows(PC),d0
  5032.         lsr.w   #1,d0
  5033.         add.w   d4,d0
  5034. 702$        move.l  numlines(PC),d3
  5035.         subq    #1,d3
  5036.         cmp.w   d3,d0
  5037.         ble.s   703$
  5038.         move.w  d3,d0
  5039. 703$        move.w  d0,edline
  5040.         sub.w   d4,d0
  5041.         lsl.w   #3,d0
  5042.         add.w   #18,d0
  5043.         move.w  d0,cposy
  5044.         clr.w   bottomin
  5045.         tst.w   loffset
  5046.         beq.s   704$
  5047.         clr.w   loffset
  5048.         bsr     blastout
  5049. 704$        bra     100$
  5050.  
  5051. 799$        cmp.b   #8,0(a2,d3)         ;Backspace
  5052.         bne.s   114$
  5053.         tst.w   d4
  5054.         beq     102$
  5055.         bsr     delchar
  5056.         subq    #1,d4
  5057.         move.w  d4,curpos
  5058.         bra     102$
  5059.  
  5060. 114$        cmp.b   #127,0(a2,d3)       ;del
  5061.         bne.s   150$
  5062. 178$        cmp.w   ibufferlen(PC),d4
  5063.         bge     102$
  5064.         addq    #1,d4
  5065.         bsr     delchar
  5066.         bra     102$
  5067.  
  5068. 150$        cmp.b   #9,0(a2,d3)         ;tab
  5069.         bne     197$
  5070.         move.w  cmdcompflag(PC),d0
  5071.         bpl.s   151$
  5072.         move.w  curpos(PC),cmdcomplen
  5073. 151$        move.w  #1,cmdcompflag
  5074. 155$        move.w  cmdcompnr(PC),d0
  5075.         bsr     getcmdptr
  5076.         move.l  d0,a0
  5077.         move.w  cmdcomplen(PC),d4
  5078.         lea     inputbuffer,a1
  5079.         subq    #1,d4
  5080. 152$        tst.b   0(a0)
  5081.         beq.s   153$
  5082.         cmp.b   (a0)+,(a1)+
  5083.         bne.s   153$
  5084.         dbf     d4,152$
  5085.         move.l  d0,a1
  5086.         lea     inputbuffer,a0
  5087. 154$        move.b  (a1)+,(a0)+
  5088.         dbeq.s  d4,154$
  5089.         neg.w   d4
  5090.         subq    #1,d4
  5091.         move.w  d4,curpos
  5092.         move.w  d4,ibufferlen
  5093.         add.w   #1,cmdcompnr
  5094.         cmp.w   #cmdnum,cmdcompnr
  5095.         beq.s   156$
  5096.         bra     100$
  5097. 153$        move.w  cmdcompnr(PC),d0
  5098.         addq    #1,d0
  5099.         move.w  d0,cmdcompnr
  5100.         cmp.w   #cmdnum,d0
  5101.         bmi.s   155$
  5102. 156$        clr.w   cmdcompnr
  5103.         bra     100$
  5104.  
  5105. 197$        cmp.b   #3,0(a2,d3)         ;ctrl c
  5106.         bne.s   104$
  5107.         move.b  #1,cbreak
  5108.  
  5109. 104$        tst.b   addlines
  5110.         bne     processnxtmsg
  5111.         cmp.b   #$18,0(a2,d3)       ;ctrl x
  5112.         bne.s   300$
  5113.         clr.w   ibufferlen
  5114.         clr.w   curpos
  5115.         bra     100$
  5116.  
  5117. 300$        cmp.b   #$19,0(a2,d3)       ;ctrl y
  5118.         bne.s   106$
  5119.         move.w  curpos,ibufferlen
  5120.         bra     100$
  5121.  
  5122. 106$        move.w  #$100,d5        ;NumPad
  5123.         and.w   qualifier(PC),d5
  5124.         beq     105$
  5125.         move.l  firstline(PC),d5
  5126.  
  5127.         cmp.b   #'7',0(a2,d3)       ;'Home'
  5128.         bne.s   200$
  5129.         moveq   #0,d5
  5130. 199$        move.l  d5,firstline
  5131.         bsr     blastout
  5132.         tst.w   bottomin
  5133.         bne.s   196$
  5134.         move.w  edline(PC),d0
  5135.         move.l  firstline(PC),d1
  5136.         cmp.w   d1,d0
  5137.         bmi.s   190$
  5138.         add.w   rows(PC),d1
  5139.         cmp.w   d1,d0
  5140.         bmi.s   192$
  5141. 190$        clr.w   curpos
  5142.         clr.w   ibufferlen
  5143.         move.w  rows(PC),d0
  5144.         lsr.w   #1,d0
  5145.         ext.l   d0
  5146.         add.l   firstline(PC),d0
  5147.         cmp.l   numlines(PC),d0
  5148.         bmi.s   191$
  5149.         move.l  numlines(PC),d0
  5150.         subq    #1,d0
  5151. 191$        move.w  d0,edline
  5152. 192$        bsr     getcurpos
  5153.         bsr     UpdateIArea
  5154. 196$        bra     100$
  5155.  
  5156. 200$        cmp.b   #'8',0(a2,d3)       ;'up arrow'
  5157.         bne.s   201$
  5158.         tst     d5
  5159.         beq     100$
  5160.         subq    #1,d5
  5161.         bra.s   199$
  5162.  
  5163. 201$        cmp.b   #'9',0(a2,d3)       ;'PgUp'
  5164.         bne.s   203$
  5165.         sub.w   rows(PC),d5
  5166.         bpl.s   199$
  5167.         moveq   #0,d5
  5168.         bra.s   199$
  5169.  
  5170. 203$        cmp.b   #'1',0(a2,d3)       ;'End'
  5171.         bne.s   205$
  5172. 222$        move.l  numlines(PC),d5
  5173.         sub.w   rows(PC),d5
  5174.         bpl     199$
  5175.         moveq   #0,d5
  5176. 204$        bra     199$
  5177.  
  5178. 205$        cmp.b   #'2',0(a2,d3)       ;'down arrow'
  5179.         bne.s   206$
  5180.         move.l  d5,d2
  5181.         add.w   rows(PC),d2
  5182.         cmp.l   numlines(PC),d2
  5183.         bge     100$
  5184.         addq    #1,d5
  5185.         bra     199$
  5186.  
  5187. 206$        cmp.b   #'3',0(a2,d3)       ;'PgDn'
  5188.         bne.s   500$
  5189.         add.w   rows(PC),d5
  5190.         move.l  d5,d2
  5191.         add.w   rows(PC),d2
  5192.         cmp.l   numlines(PC),d2
  5193.         bge.s   222$
  5194.         bra     199$
  5195.  
  5196. 500$        cmp.b   #'4',0(a2,d3)       ;left arrow
  5197.         bne.s   501$
  5198.         tst.w   bottomin
  5199.         beq     102$
  5200.         move.w  loffset(PC),d2
  5201.         sub.w   colms(PC),d2
  5202.         bpl.s   502$
  5203.         moveq   #0,d2
  5204. 502$        move.w  d2,loffset
  5205.         bsr     blastout
  5206.         bra     100$
  5207.  
  5208. 501$        cmp.b   #'6',0(a2,d3)       ;right arrow
  5209.         bne.s   170$
  5210.         tst.w   bottomin
  5211.         beq     102$
  5212.         move.w  loffset(PC),d2
  5213.         add.w   colms(PC),d2
  5214.         bra.s   502$
  5215.  
  5216. 170$        cmp.b   #'0',0(a2,d3)       ;Ins
  5217.         bne.s   177$
  5218.         eor.b   #1,insmode
  5219.         bra.s   102$
  5220.  
  5221. 177$        cmp.b   #'.',0(a2,d3)       ;Del
  5222.         beq     178$
  5223.  
  5224. 105$        tst.w   bottomin
  5225.         bne.s   777$
  5226.         tst.w   curpos
  5227.         bne.s   777$
  5228.         movem.l d0-d1,-(a7)
  5229.         move.w  edline(PC),d0
  5230.         bsr     findline
  5231.         movem.l (a7)+,d0-d1
  5232.         tst.l   8(a5)
  5233.         beq     intuiend
  5234. 777$        move.w  curpos(PC),d5
  5235.         ext.l   d5
  5236.         moveq   #79,d2
  5237.         cmp.w   d2,d5
  5238.         bge     102$
  5239.         tst.b   insmode
  5240.         beq.s   172$
  5241.         cmp.w   ibufferlen(PC),d5
  5242.         bmi.s   171$
  5243.         bra.s   173$
  5244. 172$        sub     d5,d2
  5245.         lea     80(a1),a4
  5246.         lea     79(a1),a3
  5247. 103$        move.b  -(a3),-(a4)
  5248.         dbf     d2,103$
  5249. 173$        addq.w  #1,ibufferlen
  5250. 171$        move.b  0(a2,d3),0(a1,d5)
  5251.         addq.w  #1,curpos
  5252. 102$        subq    #1,d0
  5253.         addq    #1,d3
  5254.         bra     101$
  5255.  
  5256. 100$        bsr     UpdateIArea
  5257.         bra     intuiend
  5258.  
  5259. got_enter   bsr     puthist
  5260. got_fkey    bsr     stoptimer
  5261.         clr.b   insmode
  5262.         lea     dummy,a1
  5263.         lea     inputbuffer,a2
  5264.         move.w  ibufferlen(PC),d2
  5265.         beq.s   2$
  5266.         tst.w   bottomin
  5267.         bne.s   5$
  5268.         movem.l a1-a2,-(a7)
  5269.         move.w  edline(PC),d0
  5270.         bsr     findline
  5271.         move.l  8(a5),d0
  5272.         bsr     gthex
  5273.         lea     hexarea(PC),a0
  5274.         lea     0(a2,d2),a1
  5275.         move.b  #' ',(a1)+
  5276.         move.b  #'$',(a1)+
  5277.         moveq   #8,d0
  5278.         CALL    CopyMem,_SysBase(PC)
  5279.         move.w  ibufferlen(PC),d2
  5280.         add.w   #10,d2
  5281.         move.w  d2,ibufferlen
  5282.         movem.l (a7)+,a1-a2
  5283. 5$        subq    #1,d2
  5284. 1$        move.b  (a2)+,(a1)+
  5285.         dbf     d2,1$
  5286. 2$        move.b  #10,(a1)+
  5287.         move.w  ibufferlen(PC),d0
  5288.         ext.l   d0
  5289.         addq    #1,d0
  5290.         move.l  d0,-(a7)
  5291.         clr.w   ibufferlen
  5292.         tst.w   bottomin
  5293.         bne.s   4$
  5294.         move.w  #100,curpos
  5295.         bsr     UpdateIArea
  5296. 4$        clr.w   curpos
  5297.         move.w  #1,bottomin
  5298.         bsr     getcurpos
  5299.         bsr     UpdateIArea
  5300.         move.l  (a7)+,d0
  5301.         move.w  d0,repeatlen
  5302.         clr.w   repeat
  5303.         clr.b   printed
  5304.         tst.w   getanswer
  5305.         beq.s   6$
  5306.         rts
  5307. 6$        bsr     cli
  5308.         tst.b   printed
  5309.         bne.s   3$
  5310.         bsr     starttimer
  5311. 3$        bra     intuiend
  5312.  
  5313. notarawkey
  5314.  
  5315. intuiend    bsr.s   replyintui
  5316.         bra     nextimsg
  5317. processnxtmsg
  5318.         tst.b   addlines
  5319.         beq.s   1$
  5320.         rts
  5321. 1$        bra     processmsgs
  5322.  
  5323. replyintui  move.l  intuimsg(PC),d0
  5324.         beq.s   1$
  5325.         move.l  d0,a1
  5326.         CALL    ReplyMsg,_SysBase
  5327. 1$        clr.l   intuimsg
  5328.         rts
  5329.  
  5330. ;put an input line into the history buffer
  5331. puthist     move.w  ibufferlen(PC),d5
  5332.         move.l  d5,d0
  5333.         cmp.w   minnumchars(PC),d0
  5334.         bcs     1$
  5335.  
  5336.         move.l  gothline(PC),d1
  5337.         beq.s   5$
  5338.         move.l  d1,a2
  5339.         cmp.w   8(a2),d5
  5340.         bne.s   5$
  5341.         lea     10(a2),a2
  5342.         lea     inputbuffer,a1
  5343.         subq    #1,d0
  5344. 6$        cmp.b   (a2)+,(a1)+
  5345.         bne.s   5$
  5346.         dbf     d0,6$
  5347.         move.l  gothline,curhist
  5348.         bra.s   1$
  5349.  
  5350. 5$        move.w  d5,d0
  5351.         ext.l   d0
  5352.         add     #10,d0
  5353.         move.l  #$10000,d1         ;MEMF_CLEAR
  5354.         CALL    AllocMem,_SysBase(PC)
  5355.         tst.l   d0
  5356.         beq.s   1$
  5357.         move.l  d0,a0
  5358.         move.w  d5,8(a0)
  5359.         lea     10(a0),a2
  5360.         subq    #1,d5
  5361.         lea     inputbuffer,a1
  5362. 2$        move.b  (a1)+,(a2)+
  5363.         dbf     d5,2$
  5364.         move.w  hnum(PC),d5
  5365.         cmp.w   maxhlines(PC),d5
  5366.         bmi.s   3$
  5367.         bsr     remhistline
  5368.         bra.s   4$
  5369. 3$        addq    #1,d5
  5370.         move.w  d5,hnum
  5371. 4$        move.l  d0,a1
  5372.         move.l  d0,curhist
  5373.         lea     history(PC),a0
  5374.         CALL    AddTail,_SysBase(PC)
  5375. 1$        clr.l   gothline
  5376.         rts
  5377.  
  5378. ;copy a history line into the input buffer
  5379. copyhistory lea     inputbuffer,a0
  5380.         move.w  8(a1),d3
  5381.         ext.l   d3
  5382.         move.w  d3,curpos
  5383.         move.w  d3,ibufferlen
  5384.         subq    #1,d3
  5385.         lea     10(a1),a1
  5386. 1$        move.b  (a1)+,(a0)+
  5387.         dbf     d3,1$
  5388.         rts
  5389. ;remove one line from the history buffer
  5390. ;pointer to the line in A1, returns pointer to the next line in d1
  5391. remhistline move.l  d0,-(a7)
  5392.         lea     history(PC),a0
  5393.         move.l  0(a0),a5
  5394.         tst.l   0(a5)
  5395.         beq.s   1$
  5396.         CALL    RemHead,_SysBase(PC)
  5397.         move.l  a5,a1
  5398.         move.w  8(a1),d0
  5399.         add     #10,d0
  5400.         ext.l   d0
  5401.         CALL    FreeMem,_SysBase(PC)
  5402. 1$        move.l  (a7)+,d0
  5403.         rts
  5404.  
  5405. ;kill all history lines
  5406. killhistory bsr     remhistline
  5407.         move.l  history(PC),a0
  5408.         tst.l   0(a0)
  5409.         bne.s   killhistory
  5410. 2$        clr.w   hnum
  5411.         clr.l   curhist
  5412.         rts
  5413. ;delete one char from the input line
  5414. delchar     lea     inputbuffer,a3
  5415.         lea     0(a3,d4.w),a3
  5416.         lea     -1(a3),a4
  5417.         move    d4,d5
  5418. 1$        cmp.w   #78,d5
  5419.         bge.s   2$
  5420.         move.b  (a3)+,(a4)+
  5421.         addq    #1,d5
  5422.         bra.s   1$
  5423. 2$        subq.w  #1,ibufferlen
  5424.         rts
  5425.  
  5426. testsig     move.l  tasksigs(PC),d0
  5427.         btst    d1,d0
  5428.         rts
  5429.  
  5430. ;get the position of the input area
  5431. iareapos    move.l  wnptr(PC),a0
  5432.         move.w  10(a0),d0
  5433.         subq    #4,d0
  5434.         move.w  d0,ipos
  5435.         rts
  5436.  
  5437. ;Update the current position of the input line
  5438. getcurpos   tst.w   bottomin
  5439.         beq.s   1$
  5440.         move.w  ipos,cposy
  5441.         rts
  5442. 1$        move.w  edline(PC),d3
  5443.         sub.l   firstline(PC),d3
  5444.         lsl     #3,d3
  5445.         add.w   #18,d3
  5446.         move.w  d3,cposy
  5447.         rts
  5448. ;refresh the input area
  5449. UpdateIArea move.l  rastport(PC),a1
  5450.         move.l  #1,d0
  5451.         CALL    SetDrMd,gfxbase(PC)
  5452.         moveq   #6,d0
  5453.         move.w  cposy(PC),d1
  5454.         move.l  rastport(PC),a1
  5455.         CALL    Move,gfxbase(PC)
  5456.         lea     inputbuffer,a0
  5457.         move.w  ibufferlen(PC),d0
  5458.         ext.l   d0
  5459.         move.w  colms(PC),d1
  5460.         sub.w   bottomin(PC),d1
  5461.         cmp.w   d1,d0
  5462.         bmi.s   1$
  5463.         move.w  d1,d0
  5464. 1$        move.w  d0,d2
  5465.         move.l  rastport(PC),a1
  5466.         CALL    Text,gfxbase(PC)
  5467.  
  5468.         tst.w   bottomin
  5469.         bne.s   3$
  5470.         move.w  edline(PC),d0
  5471.         bsr     findline
  5472.         move.w  12(a5),d3
  5473.         sub.w   d2,d3
  5474.         bmi.s   3$
  5475.         move.w  colms(PC),d1
  5476.         sub.w   d2,d1
  5477.         bmi.s   2$
  5478.         cmp.w   d1,d3
  5479.         ble.s   4$
  5480.         move.w  d1,d3
  5481. 4$        move.w  d3,d0
  5482.         lea     14(a5,d2.w),a0
  5483.         move.l  rastport(PC),a1
  5484.         CALL    Text,gfxbase(PC)
  5485.         add.w   ibufferlen(PC),d3
  5486.         move.w  d3,d2
  5487.  
  5488. 3$        move.w  colms(PC),d0
  5489.         sub.w   bottomin(PC),d0
  5490.         move.l  blanks(PC),a0
  5491.         ext.l   d0
  5492.         sub.w   d2,d0
  5493.         bmi.s   2$
  5494.         lea     0(a0,d2.w),a0
  5495.         move.l  rastport(PC),a1
  5496.         CALL    Text,gfxbase(PC)
  5497. 2$        bsr     putcursor
  5498.         rts
  5499.  
  5500. clrcursor   moveq   #1,d7
  5501.         bra.s   ptc1
  5502. putcursor   moveq   #6,d7
  5503. ptc1        move.w  curpos(PC),d0
  5504.         move.w  colms(PC),d1
  5505.         subq    #1,d1
  5506.         sub.w   bottomin(PC),d1
  5507.         cmp.w   d0,d1
  5508.         bmi.s   1$
  5509.         move.l  rastport(PC),a1
  5510.         move.l  d7,d0
  5511.         CALL    SetDrMd,gfxbase(PC)
  5512.         move.w  cposy(PC),d1
  5513.         move.w  curpos(PC),d0
  5514.         lsl.w   #3,d0
  5515.         addq    #6,d0
  5516.         move.l  rastport(PC),a1
  5517.         CALL    Move,gfxbase(PC)
  5518.         lea     oneblank(PC),a0
  5519.         moveq   #1,d0
  5520.         move.l  rastport(PC),a1
  5521.         CALL    Text,gfxbase(PC)
  5522. 1$        rts
  5523. ;rebuild the window from scratch
  5524. setupscreen move.l  rastport(PC),a1
  5525.         moveq   #0,d0
  5526.         CALL    SetRast,gfxbase(PC)
  5527.         move.l  wnptr,a0
  5528.         CALL    RefreshWindowFrame,intuibase(PC)
  5529.         bsr     getwindowsize
  5530.         tst.w   bottomin
  5531.         bne.s   1$
  5532.         move.w  edline(PC),d0
  5533.         move.l  firstline(PC),d1
  5534.         move.w  rows(PC),d2
  5535.         move.w  d2,d4
  5536.         move.w  numlines(PC),d3
  5537.         add.w   d1,d2
  5538.         cmp.w   d2,d0
  5539.         bmi.s   2$
  5540.         lsr.w   #1,d4
  5541.         sub.w   d4,d0
  5542.         ext.l   d0
  5543.         move.l  d0,firstline
  5544. 2$        bsr     tstfirstlin
  5545. 1$        bsr     getcurpos
  5546.         bsr     putiline
  5547.         bsr     blastout
  5548.         bsr     UpdateIArea
  5549.         move.w  rows,currenty
  5550.         rts
  5551.  
  5552. putiline    move.l  rastport(PC),a1
  5553.         moveq   #1,d0
  5554.         CALL    SetAPen,gfxbase(PC)
  5555.         move.l  rastport(PC),a1
  5556.         moveq   #1,d0
  5557.         CALL    SetDrMd,gfxbase(PC)
  5558.         move.l  wnptr(PC),a5
  5559.         move.w  10(a5),d1
  5560.         sub.w   #12,d1
  5561.         moveq   #0,d0
  5562.         move.l  rastport(PC),a1
  5563.         CALL    Move,gfxbase(PC)
  5564.         move.w  8(a5),d0
  5565.         move.w  d1,-(a7)
  5566.         move.l  rastport(PC),a1
  5567.         CALL    Draw,gfxbase(PC)
  5568.         move.w  (a7)+,d1
  5569.         tst.b   ownscreen
  5570.         bne.s   1$
  5571.         move.w  8(a5),d0
  5572.         addq    #1,d1
  5573.         move.l  rastport(PC),a1
  5574.         CALL    Move,gfxbase(PC)
  5575.         sub.w   #16,d0
  5576.         move.w  d1,-(a7)
  5577.         move.l  rastport(PC),a1
  5578.         CALL    Draw,gfxbase(PC)
  5579.         move.w  (a7)+,d1
  5580.         move.w  8(a5),d0
  5581.         addq    #1,d1
  5582.         move.l  rastport(PC),a1
  5583.         CALL    Move,gfxbase(PC)
  5584.         sub.w   #16,d0
  5585.         move.l  rastport(PC),a1
  5586.         CALL    Draw,gfxbase(PC)
  5587. 1$        rts
  5588.  
  5589. getwindowsize
  5590.         bsr     freeblank
  5591.         move.l  wnptr(PC),a0
  5592.         move.w  10(a0),d0
  5593.         sub.w   #26,d0
  5594.         lsr.w   #3,d0
  5595.         move.w  d0,rows
  5596.         move.w  8(a0),d0
  5597.         sub.w   #12,d0
  5598.         lsr.w   #3,d0
  5599.         move.w  d0,colms
  5600.         ext.l   d0
  5601.         moveq   #0,d1
  5602.         move.l  d0,d6
  5603.         CALL    AllocMem,_SysBase(PC)
  5604.         move.l  d0,blanks
  5605.         move.l  d0,a0
  5606.         subq    #1,d6
  5607. 1$        move.b  #' ',(a0)+
  5608.         dbf     d6,1$
  5609.         bsr     iareapos
  5610.         rts
  5611.  
  5612. readline    move.b  #'n',inputbuffer
  5613.         tst.b   fromfile
  5614.         bne.s   1$
  5615.         move.l  #31000,firstline
  5616.         bsr     blastout
  5617.         move.w  #1,getanswer
  5618.         bsr     replyintui
  5619. 5$        bsr     processmsgs
  5620.         move.w  d0,d5
  5621.         bsr     replyintui
  5622.         subq    #1,d5
  5623.         beq.s   5$
  5624.         ori.b   #$20,inputbuffer
  5625.         clr.w   getanswer
  5626.         bsr     RestoreOutput
  5627. 1$        rts
  5628.  
  5629. ResumeOutput
  5630.         move.l  outchain(PC),d0
  5631.         move.l  d0,a1
  5632.         beq.s   2$
  5633.         move.l  numlines,oldnumlines
  5634.         move.l  firstline,oldfirstline
  5635. 4$        tst.l   0(a1)
  5636.         beq.s   3$
  5637.         move.l  0(a1),a1
  5638.         bra.s   4$
  5639. 3$        move.l  a1,lastprinted
  5640. 2$        move.l  a1,oldpageend
  5641.         rts
  5642.  
  5643. RestoreOutput
  5644.         move.l  oldpageend(PC),d3
  5645.         beq.s   1$
  5646.         move.l  oldnumlines(PC),numlines
  5647.         move.l  oldfirstline(PC),firstline
  5648.         move.l  oldlastprinted(PC),lastprinted
  5649.         move.l  d3,a1
  5650.         move.l  0(a1),a1
  5651.         bsr     killlines
  5652.         move.l  d3,a1
  5653.         clr.l   0(a1)
  5654.         bsr     blastout
  5655. 1$        rts
  5656.  
  5657. addline     movem.l d0-d6/a0-a3,-(a7)
  5658.         move.l  rastport(PC),a1
  5659.         moveq   #1,d0
  5660.         CALL    SetAPen,gfxbase(PC)
  5661.         move.l  rastport(PC),a1
  5662.         moveq   #1,d0
  5663.         CALL    SetDrMd,gfxbase(PC)
  5664.         move.w  currenty(PC),d6
  5665.         cmp.w   rows(PC),d6
  5666.         bmi.s   1$
  5667.         bsr     cls
  5668. 1$        move.l  lastprinted(PC),a0
  5669.         move.w  colms(PC),d5
  5670.         move.w  12(a0),d3
  5671.         lea     14(a0),a0
  5672.         move.w  currenty(PC),d6
  5673.         move    d6,d7
  5674.         lsl     #3,d6
  5675.         add.w   #18,d6
  5676.         moveq   #0,d4
  5677.         bsr     blastline
  5678.         addq.w  #1,currenty
  5679.         move.l  #31000,firstline
  5680.         movem.l (a7)+,d0-d6/a0-a3
  5681.         rts
  5682.  
  5683. cls        movem.l d0-d6/a0-a3,-(a7)
  5684.         move.l  rastport(PC),a1
  5685.         moveq   #1,d0
  5686.         CALL    SetAPen,gfxbase(PC)
  5687.         move.l  rastport(PC),a1
  5688.         moveq   #1,d0
  5689.         move.l  rastport(PC),a1
  5690.         CALL    SetDrMd,gfxbase(PC)
  5691.         move.w  colms(PC),d5
  5692.         clr.w   d2
  5693. 1$        move.w  d2,d6
  5694.         move    d5,d7
  5695.         lsl     #3,d6
  5696.         add.w   #18,d6
  5697.         moveq   #0,d3
  5698.         move.l  blanks(PC),a0
  5699.         bsr     blastline
  5700.         addq    #1,d2
  5701.         cmp.w   rows(PC),d2
  5702.         bmi.s   1$
  5703.         clr.w   currenty
  5704.         movem.l (a7)+,d0-d6/a0-a3
  5705.         rts
  5706.  
  5707. createscreen moveq  #1,d1
  5708.         moveq   #80,d0
  5709.         lea     buffer,a0
  5710.         sub.l   a1,a1
  5711.         CALL    GetScreenData,intuibase(PC)
  5712.         move.w  buffer+76,nsviewmode
  5713.         move.l  buffer+12,nssize
  5714.         lea     newscreen(PC),a0
  5715.         CALL    OpenScreen,intuibase(PC)
  5716.         move.l  d0,screenptr
  5717.         move.l  d0,nwscreen
  5718.         move.w  #$f,nwtype
  5719.         beq.s   setupwindow
  5720.         tst.l   wnptr
  5721.         beq.s   1$
  5722.         move.l  wnptr(PC),a0
  5723.         move.l  4(a0),window_l
  5724.         move.l  8(a0),window_w
  5725.         CALL    CloseWindow,intuibase(PC)
  5726.         clr.l   intuimsg
  5727.         clr.l   wnptr
  5728. 1$        clr.l   newwindow
  5729.         move.l  buffer+12,newwindow+4
  5730.         move.l  wnscrflags(PC),nwflgs
  5731.         move.l  wnscrflags+4(PC),nwflgs+4
  5732.         move.b  #1,ownscreen
  5733.  
  5734. setupwindow tst.b   ownscreen
  5735.         bne.s   3$
  5736.         move.l  window_l(PC),newwindow
  5737.         move.l  window_w(PC),newwindow+4
  5738.         move.w  #1,nwtype
  5739.         move.l  wnnormflgs(PC),nwflgs
  5740.         move.l  wnnormflgs+4(PC),nwflgs+4
  5741. 3$        lea     newwindow(PC),a0
  5742.         CALL    OpenWindow,intuibase(PC)
  5743.         move.l  d0,wnptr
  5744.         beq     exit
  5745.         move.l  d0,a0
  5746.         move.l  50(a0),rastport    ;wn->RPort
  5747.         move.l  86(a0),a1          ;wn->UserPort
  5748.         move.b  15(a1),d1          ;MsgPort->SigBit
  5749.         ext.w   d1
  5750.         move.w  d1,intuisig
  5751.  
  5752.         tst.b   iconifyon
  5753.         beq.s   1$
  5754.         tst.b   ownscreen
  5755.         bne.s   1$
  5756.         lea     iconifgad,a1
  5757.         moveq   #0,d0
  5758.         CALL    AddGadget,intuibase(PC)
  5759.         move.l  wnptr(PC),a0
  5760.         CALL    RefreshWindowFrame,intuibase(PC)
  5761.  
  5762. 1$        lea     tattr(PC),a0
  5763.         CALL    OpenFont,gfxbase(PC)
  5764.         tst.l   d0
  5765.         beq.s   2$
  5766.         move.l  d0,a0
  5767.         move.l  rastport(PC),a1
  5768.         CALL    SetFont,gfxbase(PC)
  5769. 2$        bsr     getwindowsize
  5770.         bsr     getcurpos
  5771.  
  5772.         bsr     putiline
  5773.         bsr     UpdateIArea
  5774.         bsr     starttimer
  5775.         bsr     showwhat
  5776.         rts
  5777.  
  5778. usescreen   tst.b   fromfile
  5779.         bne.s   1$
  5780.         tst.b   ownscreen
  5781.         bne.s   1$
  5782.         bsr     createscreen
  5783. 1$        move.b  #1,ownscreen
  5784.         rts
  5785.  
  5786. usewindow   tst.b   fromfile
  5787.         beq.s   1$
  5788.         clr.b   ownscreen
  5789.         rts
  5790. 1$        tst.b   ownscreen
  5791.         beq.s   2$
  5792.         move.l  wnptr(PC),d0
  5793.         beq.s   3$
  5794.         move.l  d0,a0
  5795.         CALL    CloseWindow,intuibase(PC)
  5796.         clr.l   wnptr
  5797.         clr.l   intuimsg
  5798. 3$        move.l  screenptr(PC),d0
  5799.         beq.s   4$
  5800.         move.l  d0,a0
  5801.         CALL    CloseScreen,intuibase(PC)
  5802.         clr.l   screenptr
  5803.         clr.b   ownscreen
  5804. 4$        bra     setupwindow
  5805. 2$        rts
  5806.  
  5807. dchange     lea     dchead(PC),a0
  5808.         bsr     puthead
  5809.         lea     tdd(PC),a1
  5810.         move.l  _SysBase(PC),a0
  5811.         lea     350(a0),a0
  5812.         CALL    FindName,_SysBase(PC)
  5813.         tst.l   d0
  5814.         beq     R_T_S
  5815.         move.l  d0,a2
  5816.         lea     32(a2),a2
  5817.         moveq   #0,d5
  5818. 2$        lea     4(a2),a2
  5819.         move.l  0(a2),d0
  5820.         beq     3$
  5821.         move.l  d0,a0
  5822.         lea     $18e(a0),a0
  5823.         CALL    Disable,_SysBase(PC)
  5824. 5$        tst.l   0(a0)
  5825.         beq.s   6$
  5826.         move.l  0(a0),a0
  5827.         bra.s   5$
  5828. 6$        lea     -4(a0),a5
  5829.         lea     buffer+100,a3
  5830. 9$        move.l  0(a5),a5
  5831.         tst.l   0(a5)
  5832.         beq.s   11$
  5833.         move.l  a5,(a3)+
  5834.         bne.s   9$
  5835. 11$        clr.l   (a3)+
  5836.         CALL    Enable,_SysBase(PC)
  5837.         lea     buffer+100,a3
  5838. 7$        move.l  (a3)+,d0
  5839.         beq.s   3$
  5840.         move.l  d0,a5
  5841.         cmp.w   #20,28(a5)
  5842.         bne.s   7$
  5843.         move.l  40(a5),a4
  5844.         move.l  a4,d0
  5845.         move.l  d0,node
  5846.         bsr     hexan
  5847.         move.l  a4,d0
  5848.         beq.s   10$
  5849.         move.l  14(a4),d0
  5850.         bsr     hexan
  5851.         move.l  18(a4),d0
  5852.         bsr     hexan
  5853. 10$        move.l  d5,d3
  5854.         or.b    #48,d3
  5855.         move.b  d3,tddrives+2
  5856.         move.l  #tddrives,d0
  5857.         bsr     putstr
  5858.         move.l  14(a5),d0
  5859.         beq.s   8$
  5860.         move.l  d0,a0
  5861.         move.l  16(a0),d0
  5862. 8$        bsr     getaskname2
  5863.         bsr     newline
  5864.         bra.s   7$
  5865. 3$        addq    #1,d5
  5866.         cmp.w   #4,d5
  5867.         bmi     2$
  5868. R_T_S        rts
  5869.  
  5870.  
  5871. DATASTART   EQU     *
  5872.  
  5873. dosbase     dc.l    0
  5874. intuibase   dc.l    0
  5875. gfxbase     dc.l    0
  5876. condev        dc.l    0
  5877. parmtxt     dc.l    0
  5878. infile        dc.l    0
  5879. ptr        dc.l    0
  5880. oldidl        dc.l    0
  5881. olddisp     dc.l    0
  5882. mysignal    dc.l    0
  5883. auxsig        dc.l    0
  5884. trapsignal  dc.l    0
  5885. iostatus    dc.l    -1
  5886. devstatus   dc.l    -1
  5887. tasksigs    dc.l    0
  5888. cancelbit   dc.l    0
  5889. cancelbnum  dc.l    0
  5890. _SysBase    dc.l    0
  5891. InputMsg    dc.l    0
  5892. InRequest   dc.l    0
  5893. startmess   dc.l    0
  5894. savedat     dc.l    0
  5895. wnptr        dc.l    0
  5896. aliaslist   dc.l    0
  5897. screenptr   dc.l    0
  5898. intuimsg    dc.l    0
  5899. mytask        dc.l    0
  5900. wbmsg        dc.l    0
  5901. pointer     dc.l    0
  5902. replyport   dc.l    0
  5903. timerport   dc.l    0
  5904. finfoptr    dc.l    0
  5905. myseg        dc.l    0
  5906. dispatches  dc.l    0
  5907. maxdisp     dc.l    0
  5908. deltadisp   dc.l    0
  5909. wbaddr        dc.l    0
  5910. node        dc.l    0
  5911. remembr     dc.l    0
  5912. remembr2    dc.l    0
  5913. captask     dc.l    0
  5914. snoopport   dc.l    0
  5915. tasksnum    dc.l    0
  5916. blanks        dc.l    0
  5917. hidestart   dc.l    0
  5918. dispnum     dc.l    0
  5919. iocount     dc.l    0
  5920. dummyinput  dc.l    0
  5921. rastport    dc.l    0
  5922. outchain    dc.l    0
  5923. firstline   dc.l    0
  5924. oldfirstline dc.l   0
  5925. timeoutm    dc.l    0
  5926. numlines    dc.l    0
  5927. oldnumlines dc.l    0
  5928. gothline    dc.l    0
  5929. lastprinted dc.l    0
  5930. oldlastprinted dc.l 0
  5931. oldpageend  dc.l    0
  5932. maxlines    dc.l    500
  5933. realstack   dc.l    0
  5934.  
  5935.  
  5936. wnnormflgs  dc.l    $646
  5937.         dc.l    $1104f
  5938.  
  5939. wnscrflags  dc.l    $600
  5940.         dc.l    $31948
  5941.  
  5942. fkeys        dc.l    *+4
  5943.         dc.l    0
  5944.         dc.l    fkeys
  5945.  
  5946. history     dc.l    *+4
  5947.         dc.l    0
  5948.         dc.l    history
  5949. curhist     dc.l    0
  5950.  
  5951. secs        dc.l    0
  5952. mics        dc.l    0
  5953. time10        dc.l    0
  5954.  
  5955. tattr        dc.l    fontname
  5956.         dc.w    8
  5957.         dc.w    0
  5958.  
  5959. stplist     dc.l    lh_tail
  5960. lh_tail     dc.l    0
  5961.         dc.l    stplist
  5962.         dc.b    1
  5963.         dc.b    0
  5964.  
  5965. InInterrupt dc.l    0        ;ln_Succ
  5966.         dc.l    0        ;ln_Pred
  5967.         dc.b    2        ;ln_Type
  5968.         dc.b    60        ;ln_Pri
  5969.         dc.l    xopsleep    ;ln_Name
  5970.         dc.l    0        ;is_Data
  5971.         dc.l    Keyhandler    ;is_Code()
  5972.  
  5973. IOCounter   dc.l    0        ;ln_Succ
  5974.         dc.l    0        ;ln_Pred
  5975.         dc.b    2        ;ln_Type
  5976.         dc.b    -1        ;ln_Pri
  5977.         dc.l    IOcntname    ;ln_Name
  5978.         dc.l    0        ;is_Data
  5979.         dc.l    countio    ;is_Code()
  5980.  
  5981. newwindow   dc.w    0,0
  5982.         dc.w    500,100
  5983.         dc.b    0,1
  5984. nwflgs        dc.l    $646
  5985.         dc.l    $1104f
  5986. wn_firstgad dc.l    0
  5987.         dc.l    0
  5988.         dc.l    windowname
  5989. nwscreen    dc.l    0
  5990.         dc.l    0
  5991.         dc.w    110,50
  5992.         dc.w    808,-1
  5993. nwtype        dc.w    1
  5994.  
  5995. newscreen   dc.w    0,0
  5996. nssize        dc.w    0,0
  5997.         dc.w    1
  5998.         dc.b    0
  5999.         dc.b    1
  6000. nsviewmode  dc.w    0
  6001.         dc.w    $1f
  6002.         dc.l    0
  6003.         dc.l    windowname
  6004.         dc.l    0,0
  6005.  
  6006. excpterror  dc.l    0
  6007. excpttask   dc.l    0
  6008. excptaddr   dc.l    0
  6009. excptpc     dc.l    0
  6010.  
  6011. window_l    dc.w    0
  6012. window_t    dc.w    0
  6013. window_w    dc.w    550
  6014. window_h    dc.w    200
  6015.  
  6016. colms        dc.w    0
  6017. timersig    dc.w    0
  6018. intuisig    dc.w    0
  6019. ibufferlen  dc.w    0
  6020. cposy        dc.w    0
  6021. curpos        dc.w    0
  6022. bottomin    dc.w    1
  6023. ipos        dc.w    0
  6024. hnum        dc.w    0
  6025. minnumchars dc.w    2
  6026. maxhlines   dc.w    10
  6027. qualifier   dc.w    0
  6028. rows        dc.w    0
  6029. maxllength  dc.w    0
  6030. loffset     dc.w    0
  6031. repeat        dc.w    0
  6032. repeatlen   dc.w    0
  6033. edline        dc.w    999
  6034. cmdptr        dc.w    0
  6035. getanswer   dc.w    0
  6036. currenty    dc.w    0
  6037. cmdcompnr   dc.w    0
  6038. cmdcomplen  dc.w    -1
  6039. cmdcompflag dc.w    0
  6040.  
  6041. binarea     dc.b    '          ',0
  6042.         EVEN
  6043. minus        dc.b    '  '
  6044. decimal     dc.b    '    ',0
  6045. entries     dc.b    0
  6046. timeout     dc.b    5
  6047. procnum     dc.b    0
  6048. timerstate  dc.b    0
  6049. running     dc.b    0
  6050. newpri        dc.b    0
  6051. tasktyp     dc.b    0
  6052. background  dc.b    0
  6053. bool        dc.b    0
  6054. printed     dc.b    0
  6055. cbreak        dc.b    0
  6056. usageflag   dc.b    0
  6057. mnflag        dc.b    1
  6058. tports        dc.b    1
  6059. headon        dc.b    1
  6060. hideon        dc.b    1
  6061. sorton        dc.b    1
  6062. wanttraps   dc.b    0
  6063. addlines    dc.b    0
  6064. eof        dc.b    0
  6065. fromfile    dc.b    0
  6066. iconifyon   dc.b    1
  6067. gotguru     dc.b    0
  6068. ownscreen   dc.b    0
  6069. insmode     dc.b    0
  6070. cmdcli        dc.b    1
  6071. params        dc.b    'tfdlrempisc'
  6072. parmnum     equ     *-params
  6073.         dc.b    0
  6074. t2header    dc.b    '   ID     STATE   SIGALLOC SIGWAIT  SIGRECVD    PC    TASKNAME',0
  6075. theader     dc.b    '   ID     TYPE      STATE    PRI  CPUSE NUM TASKNAME',0
  6076. lheader     dc.b    '  NODE   CNT VER REV  FLAGS    ',0
  6077. libnam        dc.b    'LIBRARY NAME',0
  6078. devnam        dc.b    'DEVICE NAME',0
  6079. resnam        dc.b    'RESOURCE NAME',0
  6080. mheader     dc.b    ' LOWER   UPPER      FREE ATTR  PRI HUNK NAME',0
  6081. cr        dc.b    10,0
  6082. iheader     dc.b    '  NODE     DATA     CODE    PRI T S   TYPE     INTERRUPT NAME',0
  6083. inheader    dc.b    '  NODE     DATA     CODE    PRI NAME',0
  6084. rheader     dc.b    '  ADDR    PRI  FLAGS     VER   TYPE    RESIDENT NAME',0
  6085. pheader     dc.b    '  NODE   PORTNAME        FLAGS SIGBT NUM SIGTASK',0
  6086. hunkheader  dc.b    ' NUM  BCPL    DATA     LENGTH',0
  6087. ddheader    dc.b    'DEVICE    HDS SECTORS  TRACKS BUFFERS STATE    HANDLER',0
  6088. cdheader    dc.b    'PROCESSNAME    CURRENT DIRECTORY',0
  6089. ofheader    dc.b    '  LOCK   ACCESS  SIZE   PATH/FILENAME',0
  6090. scrheader   dc.b    'NUM   ADDR   TITLE',0
  6091. wnheader    dc.b    ' ADDR    OWNERTASK   TITLE',0
  6092. fohead        dc.b    '  NODE   CNT  Y   X  TYPE  LO  HI NAME',0
  6093. kickhead    dc.b    'START    END      LENGTH',0
  6094. snoophead   dc.b    'ACTION REQUIREMENTS        LENGTH   FROM    TO       CALLER',0
  6095. stackhead   dc.b    'SPLower     SIZE    USED TASKNAME',0
  6096. clicomhead  dc.b    '   ID    STATE    TYPE  MODE NUM PROCESSNAME      COMMAND',0
  6097. tiohead     dc.b    'IORQUEST  UNIT   SECS  REQUESTING TASK',0
  6098. dchead        dc.b    '  NODE     DATA     CODE   UNIT TASK',0
  6099. alhead        dc.b    'ALIAS NAME        COMMAND',0
  6100. tdd        dc.b    'trackdisk.device',0
  6101. tddrives    dc.b    'DF : ',0
  6102. timerunits  dc.b    'MicroHz ',0
  6103.         dc.b    'VBlank  ',0
  6104. access        dc.b    ' Read  ',0
  6105.         dc.b    ' Write ',0
  6106. romfnt        dc.b    'Rom  ',0
  6107. diskfnt     dc.b    'Disk ',0
  6108. wbname        dc.b    'Workbench',0
  6109. status        dc.b    'Added    ',0
  6110.         dc.b    'Running  ',0
  6111.         dc.b    'Ready    ',0
  6112.         dc.b    'Waiting  ',0
  6113.         dc.b    'Exeption ',0
  6114.         dc.b    'Removed  ',0
  6115.         dc.b    'Frozen   ',0
  6116.         dc.b    'Frozen   ',0
  6117. type        dc.b    'Unknown   ',0
  6118. tasktype    dc.b    'Task      ',0
  6119.         dc.b    'Interrupt ',0
  6120.         dc.b    'Device    ',0
  6121.         dc.b    'Msgport   ',0
  6122.         dc.b    'Message   ',0
  6123.         dc.b    'Freemsg   ',0
  6124.         dc.b    'Replymsg  ',0
  6125.         dc.b    'Resource  ',0
  6126.         dc.b    'Library   ',0
  6127.         dc.b    'Memory    ',0
  6128. softinttype dc.b    'Softint   ',0
  6129.         dc.b    'Font      ',0
  6130. proctype    dc.b    'Process   ',0
  6131.         dc.b    'Semaphore ',0
  6132. mp_flags    dc.b    'Signal  ',0
  6133.         dc.b    'Softint ',0
  6134.         dc.b    'Ignore  ',0
  6135. windowname  dc.b    'Xoper V2.2 (c) 1989 Werner G',$fc,'nther',0
  6136. newname     dc.b    'Xoper',0
  6137. memportname dc.b    'MemSnoop',0
  6138. xopcon        dc.b    'XopPackets',0
  6139. xopsleep    dc.b    'Xop-A-A-x',0
  6140. IOcntname   dc.b    'Xop-I/O-counter',0
  6141.  
  6142. cmdnum        set      0
  6143. commds        ADDCMD  'time'
  6144.         ADDCMD  'taskpri'
  6145.         ADDCMD  'info'
  6146.         ADDCMD  'pri'
  6147.         ADDCMD  'flush'
  6148.         ADDCMD  'freeze'
  6149.         ADDCMD  'warm'
  6150.         ADDCMD  'signal'
  6151.         ADDCMD  'break'
  6152.         ADDCMD  'alert'
  6153.         ADDCMD  'lastalert'
  6154.         ADDCMD  'hold'
  6155.         ADDCMD  'exit'
  6156.         ADDCMD  'clear'
  6157.         ADDCMD  'cancel'
  6158.         ADDCMD  'taskports'
  6159.         ADDCMD  'hunks'
  6160.         ADDCMD  'devices'
  6161.         ADDCMD  'openlib'
  6162.         ADDCMD  'closelib'
  6163.         ADDCMD  'currentdir'
  6164.         ADDCMD  'cd'
  6165.         ADDCMD  'mypri'
  6166.         ADDCMD  'files'
  6167.         ADDCMD  'locks'
  6168.         ADDCMD  'unlock'
  6169.         ADDCMD  'screens'
  6170.         ADDCMD  'windows'
  6171.         ADDCMD  'closescreen'
  6172.         ADDCMD  'closewindow'
  6173.         ADDCMD  'fonts'
  6174.         ADDCMD  'windowfonts'
  6175.         ADDCMD  'lockdrive'
  6176.         ADDCMD  'freedrive'
  6177.         ADDCMD  'capture'
  6178.         ADDCMD  'clrcold'
  6179.         ADDCMD  'clrcool'
  6180.         ADDCMD  'clrwarm'
  6181.         ADDCMD  'snoop'
  6182.         ADDCMD  'usage'
  6183.         ADDCMD  'inputhandler'
  6184.         ADDCMD  'header'
  6185.         ADDCMD  'sort'
  6186.         ADDCMD  'hide'
  6187.         ADDCMD  'hidden'
  6188.         ADDCMD  'window'
  6189.         ADDCMD  'kill'
  6190.         ADDCMD  'iconifyoff'
  6191.         ADDCMD  'historylines'
  6192.         ADDCMD  'minimumchars'
  6193.         ADDCMD  'showhistory'
  6194.         ADDCMD  'repeat'
  6195.         ADDCMD  'remresident'
  6196.         ADDCMD  'saveoutput'
  6197.         ADDCMD  'killhistory'
  6198.         ADDCMD  'backdropicon'
  6199.         ADDCMD  'setfont'
  6200.         ADDCMD  'trapguru'
  6201.         ADDCMD  'outputlines'
  6202.         ADDCMD  'usescreen'
  6203.         ADDCMD  'usewindow'
  6204.         ADDCMD  'timerio'
  6205.         ADDCMD  'diskchange'
  6206.         ADDCMD  'alias'
  6207.         ADDCMD  'remnode'
  6208.         ADDCMD  'setfkey'
  6209.         ADDCMD  'clicmd'
  6210. hexarea     dc.b    '         ',0
  6211. hextab        dc.b    '0123456789abcdef'
  6212. infoh2        dc.b    'Dispat/Sec:',0
  6213. infoh1        dc.b    'CPU:',0
  6214. infoh3        dc.b    'CPU activity: ',0
  6215. infoh6        dc.b    'Total:',0
  6216. infoh4        dc.b    '% ',0
  6217. infoh7        dc.b    'I/O Ints/Sec: ',0
  6218. cpu0        dc.b    '68000',0
  6219. cpu1        dc.b    '68010',0
  6220. cpu2        dc.b    '68020',0
  6221. cpu3        dc.b    '/68881',0
  6222. devload     dc.b    'loaded   ',0
  6223. devnload    dc.b    'unloaded ',0
  6224. inten        dc.b    'E ',0
  6225. intdis        dc.b    'D ',0
  6226. intserv     dc.b    'S ',0
  6227. inthand     dc.b    'H ',0
  6228. notfile     dc.b    '--- ------- ------- ------- ',0
  6229. longnix     dc.b    '-'
  6230. smallnix    dc.b    '----'
  6231. nix        dc.b    '--- ',0
  6232. noinfo        dc.b    'No Info on'
  6233. oneblank    dc.b    ' ',0
  6234. equal        dc.b    '=  ',0
  6235. openbrak    dc.b    '[ ',0
  6236. closebrak   dc.b    ' ]',0
  6237. namerr        dc.b    'Unable to find ',0
  6238. fonterr     dc.b    "Can't open ",0
  6239. adrerr        dc.b    'Address Error!',0
  6240. aliaserr    dc.b    'Single character alias names using "',0
  6241. aliaserr2   dc.b    '"',10,'are not allowed.',0
  6242. noworkbench dc.b    "Workbench isn't active !",0
  6243. openerr     dc.b    'Could not open file ',0
  6244. noderr        dc.b    "Can't find this Node. Continue anyway ? (Y/N)",0
  6245. listerr     dc.b    'Unable to find ListHeader. Sort aborted.',0
  6246. wiwerr        dc.b    'Script file only',0
  6247. gurutxt     dc.b    'Guru Meditation #',0
  6248. clrtxt        dc.b    'Memory Hunks cleared.',0
  6249. canerr0     dc.b    'Process is not a CLI-task',10
  6250.         dc.b    'Has it been started from Workbench ? (Y/N)',10,0
  6251. canerr1     dc.b    'Process was created by CreateProc()',10
  6252.         dc.b    'Shall I UnLoad() ? (Y/N)',10,0
  6253. unloaderr   dc.b    "Arrrgh.. can't find segments, aborting",0
  6254. noprocs     dc.b    'Not a Process.',0
  6255. notload     dc.b    'No program loaded.',0
  6256. cliprocs    dc.b    'Cli-Process',0
  6257. procloaded  dc.b    'Loaded as a command: ',0
  6258. segloaded   dc.b    'Created by CreateProc()',0
  6259. coldtxt     dc.b    'Cold Capture: ',0
  6260. cooltxt     dc.b    'Cool Capture: ',0
  6261. warmtxt     dc.b    'Warm Capture: ',0
  6262. kicktxt     dc.b    'KickMem     : ',0
  6263. unset        dc.b    'unset',0
  6264. intnames    dc.b    'Serial Out ',0
  6265.         dc.b    'Disk Block ',0
  6266.         dc.b    'SoftInt    ',0
  6267.         dc.b    'Ports      ',0
  6268.         dc.b    'Coper      ',0
  6269.         dc.b    'Vert.Blank ',0
  6270.         dc.b    'Blitter    ',0
  6271.         dc.b    'Audio Ch.0 ',0
  6272.         dc.b    'Audio Ch.1 ',0
  6273.         dc.b    'Audio Ch.2 ',0
  6274.         dc.b    'Audio Ch.3 ',0
  6275.         dc.b    'Serial In  ',0
  6276.         dc.b    'Disk Sync  ',0
  6277.         dc.b    'External   ',0
  6278.         dc.b    'SoftInt    ',0
  6279.         dc.b    'NMI        ',0
  6280. inttyp        dc.b    0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,1
  6281. fontname    dc.b    'topaz.font',0
  6282. devicenam   dc.b    'input.device',0
  6283. timernam    dc.b    'timer.device',0
  6284. memlarg     dc.b    'LARGEST ',0
  6285. memclr        dc.b    'CLEAR ',0
  6286. memfast     dc.b    'FAST ',0
  6287. memchip     dc.b    'CHIP ',0
  6288. mempubl     dc.b    'PUBLIC ',0
  6289. failed        dc.b    'Failed !',0
  6290. allok        dc.b    'ALLOC: ',0
  6291. free        dc.b    'FREE: ',0
  6292. backg        dc.b    'Bckg ',0
  6293. foreg        dc.b    'Frgr ',0
  6294. script        dc.b    'Batch ',0
  6295. interact    dc.b    'Intct ',0
  6296. startupname dc.b    'S:Xoper.Startup',0
  6297. nameerr     dc.b    'Name or address is missing.',10
  6298. synerr        dc.b    'Syntax Error, type "?" for help',10,0
  6299. wberr        dc.b    "Can't examine Workbench locks",0
  6300. dnotf        dc.b    'Directory not found',0
  6301. notdir        dc.b    'Not a directory',0
  6302. nomount     dc.b    ' not mounted.',0
  6303. dishelp     dc.b    10,'Names are case sensitive and followed by a ":"',0
  6304. unlerr        dc.b    'Lock not found',0
  6305. unl1        dc.b    'Lock is on ',0
  6306. unltxt        dc.b    'Old lock was: ',0
  6307. unltxt2     dc.b    'Unlock ? (Y/N)',10,0
  6308. scnofound   dc.b    'Screen not found.',0
  6309. winnofound  dc.b    'Window not found.',0
  6310. stperr        dc.b    'Task must be "READY" or "WAITING"',10,0
  6311. waerr        dc.b    'Task must be "FROZEN"',10,0
  6312. whatsthis   dc.b    '???.?',0
  6313. toomuch     dc.b    '??? ',0
  6314. timenotset  dc.b    ' disabled.',0
  6315. whattime    dc.b    'Refresh time in secs:',0
  6316. stoped        dc.b    '<Break>',0
  6317. onscr        dc.b    'On Screen: ',0
  6318. whatnow     dc.b    'Kill, ignore (K/I)?',0
  6319. noguru        dc.b    'None found.',0
  6320. softfail    dc.b    'Software failure!',10,'Task: ',0
  6321. addrserr    dc.b    'Bad aligned address was: ',0
  6322. procount    dc.b    'PC: ',0
  6323. diskfont    dc.b    'diskfont.library',0
  6324. usetxt        dc.b    'USAGE: Xoper [T] [F] [L] [D] [R] [E] [M] [P] [I] [S] [C]',10
  6325.         dc.b    'OR     Xoper -b',10
  6326.         dc.b    'DISPLAY:',10
  6327.         dc.b    '[T]asks    [F]=taskflags [L]ibraries [D]evices    [R]esources',10
  6328.         dc.b    'r[E]sident [M]emory      [P]orts     [I]nterrupts [S]tack',10
  6329.         dc.b    '[C]litasks [Q]uit',10,10
  6330.         dc.b    'OTHER SYSTEM LISTS:',10
  6331.         dc.b    'Windows    Screens      Fonts       WindowFonts  CurrentDir',10
  6332.         dc.b    'Files      Locks        Devices     InputHandler Capture',10
  6333.         dc.b    'TimerIO    DiskChange',10,10
  6334.         dc.b    'COMMANDS:',10
  6335.         dc.b    'Time         <secs>',10
  6336.         dc.b    'Taskpri      <priority>  [processnum] <taskname>',10
  6337.         dc.b    'Mypri        <priority>',10
  6338.         dc.b    'Signal       <mask(hex)> [processnum] <taskname>',10
  6339.         dc.b    'Break        [processnum] <taskname>',10
  6340.         dc.b    'Freeze|Warm  [processnum] <taskname>',10
  6341.         dc.b    'Kill         [processnum] <taskname>',10
  6342.         dc.b    'Snoop        [processnum] <taskname>',10
  6343.         dc.b    'Hide         <taskname>',10
  6344.         dc.b    'Pri          <priority> <nodename>',10
  6345.         dc.b    'Info         <name>',10
  6346.         dc.b    'RemResident  <resident module name>',10
  6347.         dc.b    'Clear        <longword(hex)>',10
  6348.         dc.b    'Hunks        [processnum] <procname>',10
  6349.         dc.b    'CD           <directory> [processnum] <procname>',10
  6350.         dc.b    'UnLock       <lock>',10
  6351.         dc.b    'OpenLib    | Closelib <libraryname>',10
  6352.         dc.b    'CloseWindow| Closescreen <title>',10
  6353.         dc.b    'SetFont      [size] <fontname> <windowtitle>',10
  6354.         dc.b    'LockDrive  | Freedrive   <drivename:>',10
  6355.         dc.b    'Window       <leftedge topedge width height> (scriptfile only) ',10
  6356.         dc.b    'OutputLines  <maximum # of lines>',10
  6357.         dc.b    'HistoryLines <maximum # of lines>',10
  6358.         dc.b    'MinimumChars <minimum # of characters>',10
  6359.         dc.b    'SaveOutput   <filename>',10
  6360.         dc.b    'Repeat       <Command line>',10
  6361.         dc.b    'SetFKey      <number> <string>',10
  6362.         dc.b    'Alias        [<aliasname> <commandname>]',10,10
  6363.         dc.b    'COMMANDS WITHOUT PARAMETERS:',10
  6364.         dc.b    'Flush      LastAlert    ClrCool     ClrCold      ClrWarm',10
  6365.         dc.b    'TrapGuru',10,10
  6366.         dc.b    'OPTIONS:',10
  6367.         dc.b    'Sort       TaskPorts    Hidden      Usage        Header',10
  6368.         dc.b    'IconifyOff BackDropIcon ShowHistory KillHistory  UseScreen',10
  6369.         dc.b    'UseWindow  CLICmd',10
  6370.         dc.b    'Hold       Exit'
  6371. null        dc.b    0
  6372.  
  6373.     IFD DEBUG
  6374. dosname     dc.b    'dos.library',0
  6375. intuiname   dc.b    'intuition.library',0
  6376. gfxname     dc.b    'graphics.library',0
  6377. conname     dc.b    'console.device',0
  6378.         EVEN
  6379.     ENDC
  6380.  
  6381.         BSS     blabla
  6382. buffer        ds.b    2200
  6383. out        ds.b    100
  6384. dummy        ds.b    80
  6385. in        ds.b    80
  6386. cputime     ds.b    1000
  6387. ievent        ds.b    32
  6388. outevent    ds.b    20
  6389. inputbuffer ds.b    88
  6390. repeatbuffer ds.b   81
  6391.  
  6392. mypacket    BSS     standardpacket
  6393.  
  6394. LN_SUCC     ds.l    1
  6395. LN_PRED     ds.l    1
  6396. LN_TYPE     ds.b    1
  6397. LN_PRI        ds.b    1
  6398. LN_NAME     ds.l    1
  6399. MP_FLAGS    ds.b    1
  6400. MP_SIGBIT   ds.b    1
  6401. MP_SIGTASK  ds.l    1
  6402. MN_SIZE     ds.w    1
  6403. LH_HEAD     ds.l    1
  6404. LH_TAIL     ds.l    1
  6405. LH_TAILPRED ds.l    1
  6406. LH_TYPE     ds.b    1
  6407. LH_pad        ds.b    1
  6408. dp_Link     ds.l    1
  6409. dp_Port     ds.l    1
  6410. dp_Type     ds.l    1
  6411. dp_Res1     ds.l    1
  6412. dp_Res2     ds.l    1
  6413. dp_Arg1     ds.l    1
  6414. dp_Arg2     ds.l    1
  6415. dp_Arg3     ds.l    1
  6416. dp_Arg4     ds.l    1
  6417. dp_Arg5     ds.l    1
  6418. dp_Arg6     ds.l    1
  6419. dp_Arg7     ds.l    1
  6420.  
  6421. timerio     ds.b    40
  6422.  
  6423.         CODE ICONIFY,CHIP
  6424.  
  6425. iconify     lea     icnwindow,a0
  6426.         CALL    OpenWindow,intuibase
  6427.         move.l  d0,iconwindow
  6428.  
  6429. waitforcall move.l  iconwindow,a0
  6430.         move.l  $56(a0),a0              ;wn->UserPort
  6431.  
  6432.         moveq   #0,d1
  6433.         move    d1,d0
  6434.         move.b  15(a0),d1               ;UserPort->SigBit
  6435.         bset    d1,d0
  6436.         move.l  d0,d6
  6437.         or.l    mysignal,d0
  6438.         or.l    trapsignal,d0
  6439.         CALL    Wait,_SysBase
  6440.         and.l   d0,d6
  6441.         bne.s   fromwindow
  6442.         move.l  mysignal,d1
  6443.         and.l   d0,d1
  6444.         bne     icondone
  6445.         and.l   trapsignal,d0
  6446.         beq.s   waitforcall
  6447.         move.b  #1,gotguru
  6448.         bra.s   icondone
  6449.  
  6450. fromwindow  move.l  iconwindow,a0
  6451.         move.l  $56(a0),a0              ;wn->UserPort
  6452.         CALL    GetMsg,_SysBase
  6453.         tst.l   d0
  6454.         beq.s   waitforcall
  6455.         move.l  d0,a1
  6456.         CALL    ReplyMsg,_SysBase
  6457.  
  6458.         move.l  iconwindow(PC),a0
  6459.         move.l  4(a0),d5
  6460.         cmp.l   icnwindow(PC),d5
  6461.         bne.s   1$
  6462.         lea     nsecs(PC),a0
  6463.         lea     nmics(PC),a1
  6464.         CALL    CurrentTime,intuibase
  6465.         movem.l osecs,d0-d3
  6466.         CALL    DoubleClick,intuibase
  6467.         tst.l   d0
  6468.         bne.s   icondone
  6469.         move.l  nsecs(PC),osecs
  6470.         move.l  nmics(PC),omics
  6471. 1$        move.l  d5,icnwindow
  6472.         bra     waitforcall
  6473.  
  6474. icondone    move.l  iconwindow,a0
  6475.         move.l  4(a0),icnwindow         ;LeftEdge+TopEdge
  6476.         CALL    CloseWindow,intuibase
  6477.         rts
  6478.  
  6479. osecs        dc.l    0
  6480. omics        dc.l    0
  6481. nsecs        dc.l    0
  6482. nmics        dc.l    0
  6483.  
  6484. iconwindow  dc.l    0
  6485. icnwindow   dc.w    40,170,72,28
  6486.         dc.b    0,1
  6487.         dc.l    $20,$800
  6488.         dc.l    gadget,0,0,0,0
  6489.         dc.w    72,28,72,28
  6490.         dc.w    1
  6491.  
  6492. gadget        dc.l    0
  6493.         dc.w    0,0,72,28,4,2,$20
  6494.         dc.l    image
  6495.         dc.l    0,0,0,0
  6496.         dc.w    0
  6497.         dc.l    0
  6498.  
  6499. image        dc.w    0,0,72,28,2
  6500.         dc.l    imagedata
  6501.         dc.b    3,0
  6502.         dc.l    0
  6503.  
  6504. imagedata   dc.w    $000F,$FFFF,$FFFF,$FFF8,$0000,$001F,$FFFF,$FFFF
  6505.         dc.w    $FFFC,$0000,$001F,$0000,$0000,$007C,$0000,$001F
  6506.         dc.w    $7FFF,$FFFF,$FF7C,$0000,$001F,$4A46,$0244,$557C
  6507.         dc.w    $0000,$001F,$5108,$D411,$817C,$0000,$001F,$7FFF
  6508.         dc.w    $FFFF,$FF7C,$0000,$001F,$0000,$0000,$007C,$0000
  6509.         dc.w    $001F,$30C0,$0000,$007C,$0000,$001F,$1980,$0000
  6510.         dc.w    $007C,$0000,$001F,$0F0F,$1F0F,$1F7C,$0000,$001F
  6511.         dc.w    $0619,$9999,$997C,$0000,$001F,$0F19,$999F,$987C
  6512.         dc.w    $0000,$001F,$1999,$9F18,$187C,$0000,$001F,$30CF
  6513.         dc.w    $180F,$187C,$0000,$001F,$0000,$1800,$007C,$0000
  6514.         dc.w    $001F,$0000,$0000,$007C,$0000,$001F,$FFFF,$FFFF
  6515.         dc.w    $FFFC,$0000,$000F,$FFFF,$FFFF,$FF18,$0000,$0000
  6516.         dc.w    $0000,$0000,$0000,$0000,$3FFF,$FFFF,$FFFF,$FFFF
  6517.         dc.w    $FC00,$FDFF,$FFFF,$FFFF,$FFFF,$FF00,$EBFF,$FFFF
  6518.         dc.w    $FFFF,$FFFF,$FF00,$F7FF,$FFFF,$FFFF,$F800,$0700
  6519.         dc.w    $FFFF,$FFFF,$FFFF,$FFFF,$FF00,$FFFF,$FFFF,$FFFF
  6520.         dc.w    $FFFF,$FF00,$FFFF,$FFFF,$FFFF,$FFFF,$FF00,$3FFF
  6521.         dc.w    $FFFF,$FFFF,$FFFF,$FC00,$0000,$0000,$0000,$0000
  6522.         dc.w    $0000,$0000,$0000,$0000,$0000,$0000,$0000,$FFFF
  6523.         dc.w    $FFFF,$FF80,$0000,$0000,$FFFF,$FFFF,$FF80,$0000
  6524.         dc.w    $0000,$FFFF,$FFFF,$FF80,$0000,$0000,$FFFF,$FFFF
  6525.         dc.w    $FF80,$0000,$0000,$FFFF,$FFFF,$FF80,$0000,$0000
  6526.         dc.w    $FFFF,$FFFF,$FF80,$0000,$0000,$8000,$0000,$0080
  6527.         dc.w    $0000,$0000,$8000,$0000,$0080,$0000,$0000,$8000
  6528.         dc.w    $0000,$0080,$0000,$0000,$8000,$0000,$0080,$0000
  6529.         dc.w    $0000,$8000,$0000,$0080,$0000,$0000,$8000,$0000
  6530.         dc.w    $0080,$0000,$0000,$8000,$0000,$0080,$0000,$0000
  6531.         dc.w    $8000,$0000,$0080,$0000,$0000,$FFFF,$FFFF,$FF80
  6532.         dc.w    $0000,$0000,$0000,$0000,$00E0,$0000,$0000,$0000
  6533.         dc.w    $0000,$00E0,$0000,$0000,$1FFF,$FFFF,$F800,$0000
  6534.         dc.w    $0000,$0080,$0040,$0000,$0000,$0200,$0080,$0040
  6535.         dc.w    $0000,$0000,$1400,$0080,$0040,$003F,$0000,$0800
  6536.         dc.w    $0080,$0040,$07FF,$F800,$0000,$0080,$0040,$003F
  6537.         dc.w    $0000,$0000,$0080,$0040,$0000,$3800,$FFFF,$FFFF
  6538.         dc.w    $FFFF,$FFFF,$FE00,$0000,$0080,$0040,$0000,$0000
  6539.  
  6540. iconifgad   dc.l    0
  6541.         dc.w    -83,0
  6542.         dc.w    31,10
  6543.         dc.w    $14
  6544.         dc.w    $41
  6545.         dc.w    1
  6546.         dc.l    iconifimg
  6547.         dc.l    0
  6548.         dc.l    0
  6549.         dc.l    0
  6550.         dc.l    0
  6551.         dc.w    0
  6552.         dc.l    0
  6553.  
  6554. iconifimg   dc.w    0,0
  6555.         dc.w    31,10
  6556.         dc.w    2
  6557.         dc.l    iconifdata
  6558.         dc.b    $0003,$0000
  6559.         dc.l    0
  6560.  
  6561. iconifdata  dc.w    $7FFF,$FFFC,$601F,$FFFC,$6000,$000C,$607F,$FFCC
  6562.         dc.w    $6060,$00CC,$6067,$FCCC,$7E60,$00CC,$7E7F,$FFCC
  6563.         dc.w    $7E00,$000C,$7FFF,$FFFC,$0000,$0000,$1FE0,$0000
  6564.         dc.w    $1FFF,$FFF0,$1F80,$0030,$1F9F,$FF30,$1F98,$0330
  6565.         dc.w    $019F,$FF30,$0180,$0030,$01FF,$FFF0,$0000,$0000
  6566.  
  6567.  
  6568.         END
  6569.  
  6570.